Rss & SiteMap

Foxtable(狐表) http://www.foxtable.com

新一代数据库软件,完美融合Access、Foxpro、Excel、vb.net之优势,人人都能掌握的快速软件开发工具!
共3 条记录, 每页显示 10 条, 页签: [1]
[浏览完整版]

标题:[求助]EXCEL文件中怎么复制一个工作表

1楼
sjx71 发表于:2024/9/11 12:10:00
各位老师,EXCEL文件中怎么复制一个工作表?

谢谢
图片点击可在新窗口打开查看此主题相关图片如下:无标题.jpg
图片点击可在新窗口打开查看
2楼
有点蓝 发表于:2024/9/11 12:29:00
要使用vba参考:http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=157961&authorid=0&page=1&star=2

如果不考虑合并单元格,这种方法也可以,原理就是添加一个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()
3楼
sjx71 发表于:2024/9/11 13:40:00
谢谢蓝老师,好复杂,要是有个copy方法就好多了
共3 条记录, 每页显示 10 条, 页签: [1]

Copyright © 2000 - 2018 foxtable.com Tel: 4000-810-820 粤ICP备11091905号

Powered By Dvbbs Version 8.3.0
Processed in .01953 s, 2 queries.