以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 如何只导出大于0的文件内容 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=125732) |
-- 作者:lhm11111 -- 发布时间:2018/10/5 13:04:00 -- 如何只导出大于0的文件内容 Dim dt As Table = Tables("表B") Dim Book As New XLS.Book \'定义一个Excel工作簿 Dim Sheet As XLS.Sheet = Book.Sheets(0) \'引用工作簿的第一个工作表 Dim Style As Xls.Style = Book.NewStyle \'新建一个样式 Style.BackColor = Color.Red \'样式的背景颜色设为红色 For c As Integer = 0 To dt.Cols.Count -1 \'添加列标题 Sheet(0, c).Value = dt.Cols(c).Name Next For r As Integer = 0 To dt.Rows.Count - 1 \'填入数据 For c As Integer = 0 To dt.Cols.Count -1 Sheet(r +1, c).Value = dt.rows(r)(c) Next If dt.rows(r)("合计") > 0 Then \'如果合计大于0 Sheet(r + 1,dt.Cols("合计").Index).Style = Style \'设置折扣单元格的样式 End If Next \'打开工作簿 Book.Save("E:\\新建文件夹\\test.xls") Dim Proc As New Process Proc.File = "E:\\新建文件夹\\test.xls" Proc.Start()
|
-- 作者:有点甜 -- 发布时间:2018/10/5 16:36:00 -- Dim dt As Table = Tables("表B") |