这个只能用标记与事件解决。
1、做个打印按钮:
Dim Book As New XLS.Book("c:\book5.xls")
For i as integer = 1 to 4
Book.Marks.Add("标记" & i,"")
next
Book.Build()
Book.Save("c:\reports\test.xls")
Dim Proc As New Process
Proc.File = "c:\reports\test.xls"
Proc.Start()
2、报表事件BuildDetail:
Select Case e.Book.TempLate
case ”book5“
For i as integer = 1 to 4
e.Book.Marks("标记" & i) = ""
next
if e.datarow isnot nothing Andalso e.datarow.Isnull("列名") = False then
dim vals() = e.datarow("列名").Split(",")
Dim cnt = Math.Min(4,vals.length)
For i as integer = 1 to cnt
e.Book.Marks("标记" & i) = "" = vals(i)
next
end if
end select