Dim nams As List(Of String)
nams = DataTables("cw1").GetValues("领料部门") '取进度表里不重复的部门名称
Dim App As New MSExcel.Application '定义EXCEL为对像'
Dim bname As String = "c:\data\总报表.xls"
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Add '创建EXCEL工作薄'
Wb.WorkSheets(3).delete '删除sheet3'
Wb.WorkSheets(2).delete '删除sheet2
Dim ws As MSExcel.WorkSheet = Wb.WorkSheets(1) '定义工作表sheet1
For Each nam As String In nams '历遍所有的部门名称
If nam <> "" Then '----如果部门名称不等于空
Dim Book As New XLS.Book (ProjectPath & "Attachments\内部厂.xls")'定义一个Excel工作簿'
Dim sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
Tables("cw1").filter = "领料部门 = '" & nam & "'" '根据领料部门名称进行筛选'
Book.Build() '建立工作薄'
Dim fl As String = "c:\data\"& nam &".xls"
Book.Save(fl) '保存工作簿
Dim Wb_temp As MSExcel.WorkBook = App.WorkBooks.Open(fl)
Dim Ws_temp As MSExcel.WorkSheet = wb_temp.WorkSheets(1)
Ws_temp.name = nam
Ws_temp.Copy(System.Reflection.Missing.Value, ws)
wb_temp.close(False, System.Reflection.Missing.Value, System.Reflection.Missing.Value)
End If
Next
ws.delete
Wb.saveas(bname)
App.Quit
.NET Framework 版本:2.0.50727.3655
Foxtable 版本:2016.7.29.1
错误所在事件:窗口,送货明细导出,Button2,Click
详细错误信息:
服务器出现意外情况。 (异常来自 HRESULT:0x80010105 (RPC_E_SERVERFAULT))