以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 是否可以基于临时表生成报表 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=145373) |
-- 作者:季朝龙 -- 发布时间:2020/1/17 15:12:00 -- 是否可以基于临时表生成报表 狐狸爸爸,我想基于临时表生成报表,但是运行后提示错误: .NET Framework 版本:4.0.30319.42000 Foxtable 版本:2019.12.8.1 错误所在事件:菜单,齐套异常,Click 详细错误信息: 该表单名称已经被使用。 代码如下: Dim dtb As New DataTableBuilder("齐套异常") \'生成临时表 dtb.AddDef("工单号", Gettype(String), 32) dtb.AddDef("产品品名", Gettype(String), 100) dtb.AddDef("预计齐套日期", Gettype(Date)) dtb.AddDef("备料料号", Gettype(String), 32) dtb.AddDef("料件品名", Gettype(String), 100) dtb.AddDef("异常_描述", Gettype(String), 225) dtb.AddDef("异常_采购部回复", Gettype(String), 225) dtb.AddDef("备注", Gettype(String), 225) dtb.Build() Dim Cols1() As String = {"工单号","产品品名","预计齐套日期","备料料号","料件品名","异常_描述","异常_采购部回复"} Dim Cols2() As String = {"工单号","产品品名","预计齐套日期","备料料号","料件品名","异常_描述","异常_采购部回复"} For Each dr1 As DataRow In DataTables("齐套信息").Select("[异常_处理结果] = 1 ") \'生成临时表 Dim dr2 As DataRow = DataTables("齐套异常").AddNew() For i As Integer = 0 To Cols1.Length -1 dr2(Cols2(i)) = dr1(Cols1(i)) Next Next Dim dt As Table = Tables("齐套异常") 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 CurrentTable.Position = r \'循环当前行 book.Sheets.Add(dt.rows(r)(0)) Dim Sheet1 As XLS.Sheet = Book.Sheets(r+1) \'循环引用工作簿的工作表 For c As Integer = 0 To dt.Cols.Count -1 Sheet(r +1, c).Value = dt.rows(r)(c) \'总表填入数据 Next Next Dim App As New MSExcel.Application \'打开工作簿 Book.Save("c:\\reports\\齐套异常.xls") \'保存 Dim Proc As New Process \'打开excel Proc.File = "c:\\reports\\齐套异常.xls" \'打开excel Proc.Start() \'打开excel App.Visible = True \'显示excel |
-- 作者:有点蓝 -- 发布时间:2020/1/17 15:16:00 -- 使用"工单号"生成sheet名称,名称不能有重复的,应该是临时表有重复的"工单号" |