这个没办法用excel报表完成,只能用专业报表:
Dim doc As New PrintDoc '定义一个报表
doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight '设置排列方式
For Each nm As String In DataTables("表A").GetUniqueValues("","存放地点")
Dim min As String = DataTables("表A").Compute("min(档号)","存放地点 = '" & nm & "'")
Dim max As String = DataTables("表A").Compute("Max(档号)","存放地点 = '" & nm & "'")
Dim rt As New prt.RenderTable() '定义一个表格对象
rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
rt.Width = 50 '表格宽度为50mm
rt.Style.Spacing.All = 2 '和其他对象之间的间隔为2mm
rt.SplitVertBehavior = prt.SplitBehaviorEnum.Never '避免垂直换页的时候,表格被分割成两部分.
rt.Cols(0).Width = 20
rt.cells(0,0).Text = "箱号"
rt.Cells(0,1).Text = nm
rt.Cells(1,0).Text = "起始档号"
rt.Cells(1,1).Text = min
rt.Cells(2,0).Text= "结束档号"
rt.cells(2,1).Text = max
doc.Body.Children.Add(rt) '将表格对象加入到报表中
Next
Doc.Preview() '预览