没办法,只能是设置列宽了
Dim ReportName As String = "ReportCheck"
'output.show(Tables("ReportCheck").GetColVisibleWidth)
Dim cwidths As String = "生产班别|198|开浇时间|98|当班浇序|98|送检记录_计划牌号|98|送检记录_冶炼炉号|98|精炼炉座|98|划坯支数|98|断面规格|98|入库_实际牌号|98|入库_出厂支数|98|入库_入库重量|98|录入状态|98|化学成份信息---单位:(%)_C|98|化学成份信息---单位:(%)_Si|98|化学成份信息---单位:(%)_Mn|98|化学成份信息---单位:(%)_P|98|化学成份信息---单位:(%)_S|98|化学成份信息---单位:(%)_Al|98|化学成份信息---单位:(%)_Als|98|化学成份信息---单位:(%)_Alt|98|化学成份信息---单位:(%)_As|98|化学成份信息---单位:(%)_B|98|化学成份信息---单位:(%)_Ni|98|化学成份信息---单位:(%)_Ceq|98|化学成份信息---单位:(%)_Cr|98|化学成份信息---单位:(%)_Cu|98|化学成份信息---单位:(%)_Mo|98|化学成份信息---单位:(%)_Nb|98|化学成份信息---单位:(%)_Pb|98|化学成份信息---单位:(%)_Ti|98|化学成份信息---单位:(%)_V|98|备注信息|98"
Dim dicWidths As new Dictionary(Of String, Double)
Dim ary() As String = cwidths.Split("|")
For i As Integer = 0 To ary.Length - 1 Step 2
dicwidths.Add(ary(i), ary(i+1))
Next
'Dim RepDr As DataRow = DataTables("Sys_Reports").SQLFind("[RepName] = '" & ReportName & "'")
Dim Report As New PrintDoc
'设置报表纸张
With Report
.Body.Children.Clear '清除原有报表数据
.PageSetting.PaperKind = 66 '设置纸张类型(A2)
.PageSetting.LeftMargin = 10 '设置左边距
.PageSetting.RightMargin = 10 '设置右边距
.PageSetting.TopMargin = 20 '设置上边距
.PageSetting.BottomMargin = 20 '设置下边距
End With
Dim ReT As Table = Tables(ReportName)
'开始写入报表
Dim prs As Integer = 10 '每页50行
For p As Integer = 0 To math.Ceiling(ReT.Rows.Count / prs) - 1
Dim rt As New prt.RenderTable
With rt
'.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
'.Width = "Parent.Width" '表格宽度为自动,也就是等于各列设置宽度之和
'.Height = "Parent.Height" '表格宽度为自动,也就是等于各列设置宽度之和
.Style.GridLines.All = New prt.LineDef(0.5, Color.Black) '边框宽度0.5毫米,颜色黑色
'Style.Font = New Font("微软雅黑",9) '报表字体
.Style.TextAlignVert = prt.AlignVertEnum.Center '报表内容水平对齐方式
.Style.TextAlignHorz = prt.AlignHorzEnum.Center '报表内容垂直对齐方式
'.Style.Spacing.All = 1 '内容和网格线的距离为
'.Style.Padding.All = 1
.Style.WordWrap = True
End With
ReT.CreateReportHeader(rt,True) '生成多层表头
For c As Integer = 0 To ReT.Cols.Count - 1
For r As Integer = p * prs To math.min(ReT.Rows.Count - 1,( p + 1) * prs - 1)
If ret.DataTable.DataCols(c).IsDate Then
rt.Cells(r - p * prs + ReT.HeaderRows, c).Text = Format(ReT.rows(r)(c),"f")
'ElseIf ret.DataTable.DataCols(c).IsNumeric Then
'rt.Cells(r - p * prs + ReT.HeaderRows, c).Text = Format(ReT.rows(r)(c),"#0.00")
Else
rt.Cells(r - p * prs + ReT.HeaderRows, c).Text = ReT.rows(r)(c)
End If
Next
If dicwidths.ContainsKey(ReT.Cols(c).name) Then
rt.Cols(c).Width = dicwidths(ReT.Cols(c).name)
End If
Next
If p < math.Ceiling(ReT.Rows.Count / prs) - 1
rt.BreakAfter = prt.BreakEnum.Page
End If
Report.Body.Children.Add(rt)
Next
Report.Preview