以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 如何将Excel中所有sheet都导入? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=192119) |
-- 作者:山中树人100 -- 发布时间:2024/5/30 0:22:00 -- 如何将Excel中所有sheet都导入? 目前以下代码已解决“”sheet1“”的导入,如何将Excel中所有sheet都导入进去? 导入代码 For Each fl As String In dlg.FileNames Dim mg As New Merger mg.SourcePath = fl if fl.EndsWith(".xls") mg.Format = "excel" \'指定格式 else mg.Format = "excel2007" \'指定格式 end if mg.SourceTableName = "sheet1$" \'指定要合并的表 mg.DataTableName = "sheet1" \'指定接收数据的表 mg.Merge() \'开始合并 Next 历遍代码 Dim Book As New XLS.Book(fl) for each Sheet As XLS.Sheet in Book.Sheets Dim mg As New Merger mg.SourcePath = fl mg.Format = "excel2007" \'指定格式 mg.SourceTableName = Sheet.name & "$" \'指定要合并的表 mg.DataTableName = "sheet1" \'指定接收数据的表 mg.Merge() \'开始合并 Next |
-- 作者:有点蓝 -- 发布时间:2024/5/30 9:04:00 -- For Each fl As String In dlg.FileNames Dim Book As New XLS.Book(fl) For Each Sheet As XLS.Sheet In Book.Sheets Dim mg As New Merger mg.SourcePath = fl If fl.EndsWith(".xls") Then mg.Format = "excel" \'指定格式 Else mg.Format = "excel2007" \'指定格式 End If mg.SourceTableName = Sheet.name & "$" \'指定要合并的表 mg.DataTableName = "sheet1" \'指定接收数据的表 mg.Merge() \'开始合并 Next Next |