以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 在已有excel表文件中增加sheet工作表出错 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=124827) |
||||
-- 作者:ZJZK2018 -- 发布时间:2018/9/14 12:19:00 -- 在已有excel表文件中增加sheet工作表出错 Dim Book As New XLS.Book("d:\\data\\工资表.xls") For Each nm As String In DataTables("工资表").GetValues("年月","年月 is not null") For Each shet As XLS.Sheet In Book.Sheets If shet.Name.Contains(nm) = False Then book.Sheets.Add(nm) End If Next Next Book.Save("d:\\data\\工资表.xls") 出现下面提示错误: |
||||
-- 作者:有点甜 -- 发布时间:2018/9/14 12:23:00 -- Dim Book As New XLS.Book("d:\\data\\工资表.xls") Dim ls As new List(Of String) For Each shet As XLS.Sheet In Book.Sheets ls.add(shet.Name) Next For Each nm As String In DataTables("工资表").GetValues("年月","年月 is not null") If ls.Contains(nm) = False Then ls.add(nm) book.Sheets.Add(nm) End If Next Book.Save("d:\\data\\工资表.xls") |
||||
-- 作者:ZJZK2018 -- 发布时间:2018/9/18 16:13:00 -- 老师下面红色部份代码出错: 需求是:根据”工资月报表“模板,生成文件一个excel文件,并根据表的月份自动增加工作表 Dim dr As Row = Tables("工资月报表").Current Dim pth As String = ProjectPath & "Reports\\工资月报表\\" & dr("年度") & "\\" If FileSys.DirectoryExists(pth) = False Then \'创建新文件夹 FileSys.CreateDirectory(pth) End If Dim Book As New XLS.Book(ProjectPath & "Attachments\\工资月报表.xls") \'提取模板 Dim fl As String = pth & dr("年度") & "-" & dr("月份") & "月份 工资月报表.xls" Book.Build() Book.Save(fl) Dim App As New MSExcel.Application Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open(fl) Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1) App.Visible = True ShowAppWindow("工资月报表",2) Ws.PrintPreview App.Quit Dim fl1 As String = pth & dr("年度") & "年度 工资月报表.xls" Dim Book1 As New XLS.Book(fl1) Dim ls As new List(Of String) For Each shet As XLS.Sheet In Book1.Sheets ls.add(shet.Name) Next For Each nm As String In DataTables("工资月报表").GetValues("月份") If ls.Contains(nm) = False Then ls.add(nm & "月份") book1.Sheets.Add(nm & "月份") End If Next Book1.Save(fl1) 错误提示: .NET Framework 版本:2.0.50727.8762 Foxtable 版本:2018.9.9.1 错误所在事件:窗口,工资表,Button2,Click 详细错误信息: 打开存储文件失败。 |
||||
-- 作者:有点甜 -- 发布时间:2018/9/18 16:35:00 -- 这个代码的路径有问题,请确认存在这个路径的文件。
Dim fl1 As String = pth & dr("年度") & "年度 工资月报表.xls" msgbox(fl1) |
||||
-- 作者:ZJZK2018 -- 发布时间:2018/9/18 16:50:00 -- 如何在一个excel表中根据“年度”,“月份”生成工资表?代码仅增加了工作表,但如何把模板内容增加进去? Dim dr As Row = Tables("工资月报表").Current Dim pth As String = ProjectPath & "Reports\\工资月报表\\" & dr("年度") & "\\" If FileSys.DirectoryExists(pth) = False Then \'创建新文件夹 FileSys.CreateDirectory(pth) End If Dim Book As New XLS.Book(ProjectPath & "Attachments\\工资月报表.xls") \'提取模板 Dim fl As String = pth & dr("年度") & "-" & dr("月份") & "月份 工资月报表.xls" Dim fl1 As String = pth & dr("年度") & "年度 工资月报表.xls" Book.Build() Book.Save(fl) Book.Save(fl1) Dim Book1 As New XLS.Book(fl1) Dim ls As new List(Of String) For Each shet As XLS.Sheet In Book1.Sheets ls.add(shet.Name) Next For Each nm As String In DataTables("工资月报表").GetValues("月份") If ls.Contains(nm) = False Then ls.add(nm & "月份") book1.Sheets.Add(nm & "月份") End If Next Book1.Save(fl1) [此贴子已经被作者于2018/9/18 16:54:51编辑过]
|
||||
-- 作者:有点甜 -- 发布时间:2018/9/18 18:46:00 -- 剪切模板过去
http://www.foxtable.com/webhelp/scr/1465.htm
|
||||
-- 作者:ZJZK2018 -- 发布时间:2018/9/18 20:09:00 -- 下面代码生成excel的工作表名称“sheet1”,如何生成:2月份,3月份,根据“dr("月份") + 月份,如何调整?谢谢 Dim dr As Row = Tables("工资月报表").Current Dim pth As String = ProjectPath & "Reports\\工资月报表\\" & dr("年度") & "\\" If FileSys.DirectoryExists(pth) = False Then \'创建新文件夹 FileSys.CreateDirectory(pth) End If Dim Book As New XLS.Book(ProjectPath & "Attachments\\工资月报表.xls") \'提取模板 Dim fl As String = pth & dr("年度") & "-" & dr("月份") & "月份 工资月报表.xls" Book.Build() Book.Save(fl)
|
||||
-- 作者:有点蓝 -- 发布时间:2018/9/18 20:21:00 -- 可以在模板里先创建好各个月份sheet,设置好模板,一起生成。狐表支持同时生成多个sheet的报表 |
||||
-- 作者:ZJZK2018 -- 发布时间:2018/9/18 20:29:00 -- 工资报表是每个月的,我的需求是:每个月生成一个工资月报表,并自动增加到另一个总Excel表中去,如5楼图一样? [此贴子已经被作者于2018/9/18 20:34:23编辑过]
|
||||
-- 作者:有点蓝 -- 发布时间:2018/9/18 20:44:00 --
|