表单全部是用专业报表输出打印的,代码全部写在配置栏的一个打印按钮上,可根据当前操作的表单运行对应的代码。类似下面这样:
.......
rt.Rows(rt.Rows.Count-1).Style.Borders.All = New prt.LineDef("0mm", Color.white) '去掉网格线
rt.Rows(rt.Rows.Count-1).Style.Borders.Top = New prt.LineDef("0.2mm", Color.Black) '恢复上方网格线
rt.Cells(rt.Rows.Count-1,0).SpanCols = 9
rt.Cells(rt.Rows.Count-1,0).Text = "第[PageNo]页,共[PageCount]页"
rt.Cells(rt.Rows.Count-1,0).Style.Font = New Font("宋体",10) '设置字体
rt.RowGroups(rt.Rows.Count-1,1).Style.TextAlignHorz = prt.AlignHorzEnum.Right '文本水平位置
rt.RowGroups(rt.Rows.Count-1,1).Footer = prt.TableHeaderEnum.All '指定表尾行
doc.Body.Children.Add(rt) '将表格对象加入到报表中
Doc.Preview() '预览报表
Case "采购单"
Dim rt As New prt.RenderTable() '定义一个表格对象
'Dim rx As New prt.RenderText '定义一个文本对象
MtbName = Tables("采购单_主表")
CurRow = Tables("采购单_主表").Current
tb = Tables("采购单_明细")
'检查当前表单是否设计了打印模板
Dim dr As DataRow = DataTables("Argtb").Find("tbN = '" & Mtb & "'")
If dr IsNot Nothing Then
'设置打印纸张
doc.PageSetting.PaperKind = dr("PaperKind")
doc.PageSetting.Landscape = dr("Landscape") '是否横向打印
Doc.PageSetting.LeftMargin = CInt(dr("PageL")) '设置左边距
Doc.PageSetting.RightMargin = CInt(dr("PageR")) '设置右边距
Doc.PageSetting.TopMargin = CInt(dr("PageT")) '设置上边距
Doc.PageSetting.BottomMargin = CInt(dr("PageB")) '设置下边距
Else
MessageBox.Show("当前表单未设计打印模板!","提示")
Return
End If
........
现在的问题是:专业报表每个表单的打印代码都很长,现在才几张表就很多了,如果有几十张或更多代码编辑器有没有限制输入内容的多少?会不会影响速度?有没有简化的方法。因为每个表单格式内容都不同又不能共用。
谢谢!