以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- [求助]EXCEL文件中怎么复制一个工作表 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=193406) |
-- 作者:sjx71 -- 发布时间:2024/9/11 12:10:00 -- [求助]EXCEL文件中怎么复制一个工作表 各位老师,EXCEL文件中怎么复制一个工作表? |
-- 作者:有点蓝 -- 发布时间:2024/9/11 12:29:00 -- 如果不考虑合并单元格,这种方法也可以,原理就是添加一个sheet,然后把之前的sheet的内容全部复制到新的sheet里 Dim Products As List(Of String) Products = DataTables("出库").SQLGetValues("出库用途") Dim Book As New XLS.Book(ProjectPath & "Attachments\\出库单.xls") \'打开模板 Dim fl As String = ProjectPath & "Reports\\出库单.xls" Dim Sheet As XLS.Sheet = Book.Sheets(0) Dim Sheet2 As XLS.Sheet If Products.Count > 0 Then Sheet(1,7).Value = "<出库用途 =\'" & Products(0) & "\'>" For i As Integer = 1 To Products.Count - 1 Book.Sheets.Add(Products(i)) Sheet2 = Book.Sheets(Products(i)) For r As Integer = 0 To Sheet.Rows.Count - 1 \'填入数据 Sheet2.Rows(r).Height = Sheet.Rows(r).Height For c As Integer = 0 To Sheet.Cols.Count -1 Sheet2.Cols(c).Width = Sheet.Cols(c).Width Sheet2(r, c).Value = Sheet(r, c).Value Sheet2(r, c).Style = Sheet(r, c).Style Next Next Sheet2(1,7).Value = "<出库用途 =\'" & Products(i) & "\'>" \'写入打印条件=\'"& Product & "\' Next Book.Build() \'生成报表 Book.Save(fl) Dim Proc As New Process Proc.File = fl Proc.Start() |
-- 作者:sjx71 -- 发布时间:2024/9/11 13:40:00 -- 谢谢蓝老师,好复杂,要是有个copy方法就好多了 |