以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.net/bbs/index.asp)
--  专家坐堂  (http://foxtable.net/bbs/list.asp?boardid=2)
----  导出的excel表零值处理  (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=194653)

--  作者:g1j2h3
--  发布时间:2025/1/2 11:36:00
--  导出的excel表零值处理
如何让导出的excel表中的0值不显示

图片点击可在新窗口打开查看此主题相关图片如下:零值.png
图片点击可在新窗口打开查看


--  作者:有点蓝
--  发布时间:2025/1/2 11:44:00
--  
怎么导的?
--  作者:g1j2h3
--  发布时间:2025/1/2 11:46:00
--  
Dim tbl As Table = Tables("统计汇总_Table4")
Dim hdr As Integer = tbl.HeaderRows \'获得表头的层数
Dim szs() As Integer = {250, 120, 50}
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim Style As XLS.Style = Book.NewStyle() \'定义新样式
Dim fnt As New Font("宋", 11)
Style.ForeColor = Color.black \'设置样式的字体颜色
Style.AlignHorz = XLS.AlignHorzEnum.Center
Style.AlignVert = XLS.AlignVertEnum.Center
tbl.CreateSheetHeader(Sheet, 1, 0, False) \'生成表头
Sheet.DefaultRowHeight = 35
Sheet.GridColor = Color.blue
For f As Integer = 0 To 2
    Sheet.Cols(f).Width = szs(f) \'指定列宽
Next

For s As Integer = 3 To tbl.Cols.Count - 1
    Sheet.Cols(s).Width = 50 \'指定列宽
Next

For c As Integer = 0 To tbl.Cols.Count - 1
    For r As Integer = 0 To tbl.Rows.Count - 1
        sheet(r + hdr + 1, c).value = tbl(r, c)
        Sheet.MergeCell(0, 0, 1, c + 1)
        Sheet(0, 0).Value = "接单送货汇总表"
        Sheet(r, c).Style = Style
        Sheet(r, c).Style.Font = fnt
    Next
Next

Dim St2 As XLS.Style = Book.NewStyle
St2.Font = New Font("微软雅黑", 15, FontStyle.Bold)
St2.AlignHorz = XLS.AlignHorzEnum.Center
St2.AlignVert = XLS.AlignVertEnum.Center
Sheet.Rows(tbl.Rows("0").Index).Style = st2



Book.Save("d:\\data\\接单送货汇总表.xls")
Dim Proc As New Process
Proc.File = "d:\\data\\接单送货汇总表.xls"
Proc.Start()

--  作者:有点蓝
--  发布时间:2025/1/2 12:02:00
--  
For c As Integer = 0 To tbl.Cols.Count - 1
    For r As Integer = 0 To tbl.Rows.Count - 1
dim a as string= tbl(r, c)
if a>""
        sheet(r + hdr + 1, c).value = a
end if
        Sheet.MergeCell(0, 0, 1, c + 1)

--  作者:g1j2h3
--  发布时间:2025/1/2 12:20:00
--  
谢谢大师