以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 批量导出excel报表 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=192787) |
-- 作者:lihe60 -- 发布时间:2024/7/22 16:35:00 -- 批量导出excel报表 帮助中介绍的是一次生成一张出库单,现需要批量导出出库单,代码怎么写? |
-- 作者:有点蓝 -- 发布时间:2024/7/22 16:40:00 -- 哪个帮助? |
-- 作者:lihe60 -- 发布时间:2024/7/22 16:51:00 -- 官方的帮助文档,如 Dim Book
As New XLS.Book(ProjectPath &
"Attachments\\出库单.xls")
Dim fl As String = ProjectPath & "Reports\\出库单.xls" book.AddDataTable("出库","数据源名称","Sel\\ect * from {出库} where 出库单编号= \'CK-20030726001\'") \'添加父表 book.AddDataTable("出库明细","数据源名称","Sel\\ect * from {出库明细} where 出库单编号= \'CK-20030726001\'") \'添加子表 book.AddRelation("出库","出库单编号","出库明细","出库单编号") \'建立关联 Book.Build() \'生成细节区 Book.Save(fl) \'保存工作簿 Dim Proc As New Process \'打开工作簿 Proc.File = fl Proc.Start() [此贴子已经被作者于2024/7/22 16:54:09编辑过]
|
-- 作者:有点蓝 -- 发布时间:2024/7/22 17:00:00 -- 比如 dim ss() as string = {"CK-20030726001","CK-20030726002") for each s as string in ss Dim Book As New XLS.Book(ProjectPath & "Attachments\\出库单.xls") Dim fl As String = ProjectPath & "Reports\\出库单" & s & ".xls" book.AddDataTable("出库","数据源名称","Sel\\ect * from {出库} where 出库单编号= \'" & s & "\'") \'添加父表 book.AddDataTable("出库明细","数据源名称","Sel\\ect * from {出库明细} where 出库单编号= \'" & s & "\'") \'添加子表 book.AddRelation("出库","出库单编号","出库明细","出库单编号") \'建立关联 Book.Build() \'生成细节区 Book.Save(fl) \'保存工作簿 next
|
-- 作者:lihe60 -- 发布时间:2024/7/22 20:04:00 -- Dim ss() As String = {"16", "17"} Dim Book As New XLS.Book(ProjectPath & "Attachments\\出库单.xlsx") Dim fl As String fl = ProjectPath & "Reports\\出库单.xls" For Each s As String In ss Dim t As Integer = s book.AddDataTable("出库", "用友", "Sel\\ect * from {g_业务} where xh= " & t) \'添加父表 book.AddDataTable("出库明细", "用友", "Sele\\ct * From {jz_业务库} where g_业务id = " & t) \'添加子表 book.AddRelation("出库", "xh", "出库明细", "g_业务id") \'建立关联 Next Book.Build() \'生成细节区 Book.Save(fl) \'保存工作簿 Dim Proc As New Process \'打开工作簿 Proc.File = fl Proc.Start() 这段代码不运行 |
-- 作者:lihe60 -- 发布时间:2024/7/22 20:04:00 -- --------------------------- 版本:2022.8.18.1 --------------------------- 代码执行出错,错误信息: System.Data.DuplicateNameException: 名为“出库”的 DataTable 已属于此 DataSet。 在 System.Data.DataTableCollection.RegisterName(String name, String tbNamespace) 在 System.Data.DataTableCollection.BaseAdd(DataTable table) 在 System.Data.DataTableCollection.Add(DataTable table) 在 Foxtable.XLS.Book.O_0__0_._.() 在 Foxtable.XLS.Book.O_0__0_._.(Int32[] A_0) 在 UserCode.Test() |
-- 作者:有点蓝 -- 发布时间:2024/7/22 20:17:00 -- 把基础学好一点吧。只能按4楼的用法,都在循环里处理 |
-- 作者:lihe60 -- 发布时间:2024/7/22 21:03:00 -- Dim ss() As String = {"17", "16", "19"} Dim fl As String For Each s As String In ss Dim Book As New XLS.Book(ProjectPath & "Attachments\\出库单.xlsx") fl = ProjectPath & "Reports\\出库单.xls" Dim t As Integer = s book.AddDataTable("出库", "用友", "Sel\\ect * from {g_业务} where xh= " & t) \'添加父表 book.AddDataTable("出库明细", "用友", "Se\\lect * From {jz_业务库} where g_业务id = " & t) \'添加子表 book.AddRelation("出库", "xh", "出库明细", "g_业务id") \'建立关联 Book.Build() \'生成细节区 Book.Save(fl) \'保存工作簿 Next Dim Proc As New Process \'打开工作簿 Proc.File = fl Proc.Start() 能运行,但没有实现连续批量生成报表的目的。
|
-- 作者:有点蓝 -- 发布时间:2024/7/22 21:05:00 -- fl = ProjectPath & "Reports\\出库单" & s & ".xls" 最后3行没有什么用,去掉
|
-- 作者:lihe60 -- 发布时间:2024/7/23 9:06:00 -- 批量单据要在同一个工作表的。 |