excel模板里面有N个工作表,每个工作表都对应定义数据来源一个数据库表,怎么实现一次填充对应表的所有数据呢?
比如工作表1对应数据库1表 工作表2对应数据库2表 工作表3对应数据库3表……
当前代码如下:BBB部分怎么写呢?或者有没有更好的操作方法呢?
Dim dt33 As String = e.Values("用户角色")
Dim dt44 As String = e.Values("监督单位")
Dim time As String =Format(Date.now,"yyyyMMddHHmmss")
Dim Book As New XLS.Book(ProjectPath & "Attachments\12+3措施台账表.xls") '打开模板
Dim fl As String = ProjectPath & "Reports\【" & Date.Today.Year & "年" & Date.Today.Month & "】12+3措施台账表.xls"
Dim Sheet As XLS.Sheet = Book.Sheets(0)
If dt33.Contains("案管办管理员") Or dt33.Contains("监督检查管理员") Then
book.AddDataTable(bbb,"主数据源","Sel ect * from {"& bbb &"} ")
else
If bbb="监督任务台账" Then
book.AddDataTable(bbb,"主数据源","Sel ect * from {"& bbb &"} where 责任单位='" & e.Values("监督单位") & "'")
Else
book.AddDataTable(bbb,"主数据源","Sele ct * from {"& bbb &"} where 监督单位='" & e.Values("监督单位") & "'")
End If
End If
Book.Build() '生成报表
Book.Save(fl)
[此贴子已经被作者于2023/3/6 9:18:19编辑过]