共22 条记录, 每页显示 10 条, 页签:
[1]
[2][3]
1楼
lihe60 发表于:2024/7/22 16:35:00
帮助中介绍的是一次生成一张出库单,现需要批量导出出库单,代码怎么写?
2楼
有点蓝 发表于:2024/7/22 16:40:00
3楼
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编辑过]
4楼
有点蓝 发表于: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
5楼
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()
这段代码不运行
6楼
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()
7楼
有点蓝 发表于:2024/7/22 20:17:00
把基础学好一点吧。只能按4楼的用法,都在循环里处理
8楼
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()
能运行,但没有实现连续批量生成报表的目的。
9楼
有点蓝 发表于:2024/7/22 21:05:00
fl = ProjectPath & "Reports\出库单" & s & ".xls"
最后3行没有什么用,去掉
10楼
lihe60 发表于:2024/7/23 9:06:00
共22 条记录, 每页显示 10 条, 页签:
[1]
[2][3]