-- 作者:有点色
-- 发布时间:2017/1/16 10:35:00
--
看懂代码,自己修改
Dim Doc As New PrintDoc \'定义一个报表 Doc.PageSetting.LeftMargin = 2 \'设置左边距 Doc.PageSetting.RightMargin = 2 \'设置右边距 Doc.PageSetting.TopMargin= 8 \'设置上边距 Doc.PageSetting.BottomMargin = 5 \'设置底边距 Doc.PageSetting.Width=89 \'宽度 Doc.PageSetting.Height=229 \'高度 Doc.PageSetting.Landscape = False \'横向打印 Doc.PageSetting.Color = False \'彩色打印 Dim _T As String \'定义一个分段文本 Dim Text8 As New prt.RenderText \'定义一个文本对象 _T="[ ]- " Text8.Text=_T.Replace("//",vbcrlf) \'分段文本 Text8.Style.TextAlignHorz=prt.AlignHorzEnum.Left \'文本对齐,水平 Text8.Style.TextAlignVert=prt.AlignVertEnum.Top \'文本对齐,垂直 Text8.Style.Font=New System.Drawing.Font("Gulim",14.25,1,3,0,False) \'文本字体 Text8.Style.Padding.All=0.5 \'单元格文本内距 Text8.Style.CharSpacing =0 \'字符间距为毫米 Text8.Style.TextIndent =0 \'首行缩进 Text8.Style.LineSpacing =100 \'设置行距 Text8.Style.BackColor=Color.FromKnownColor(164) \'背景颜色 Text8.Style.TextColor=Color.FromKnownColor(35) \'字体颜色 Text8.X=10 \'水平位置 Text8.Y=0 \'垂直位置
Dim Text18 As New prt.RenderText \'定义一个文本对象 _T="201-90-91217" Text18.Text=_T.Replace("//",vbcrlf) \'分段文本 Text18.Style.TextAlignHorz=prt.AlignHorzEnum.Left \'文本对齐,水平 Text18.Style.TextAlignVert=prt.AlignVertEnum.Top \'文本对齐,垂直 Text18.Style.Font=New System.Drawing.Font("GulimChe",11.25,0,3,1,False) \'文本字体 Text18.Style.Padding.All=0.5 \'单元格文本内距 Text18.Style.CharSpacing =0 \'字符间距为毫米 Text18.Style.TextIndent =0 \'首行缩进 Text18.Style.LineSpacing =100 \'设置行距 Text18.Style.BackColor=Color.FromKnownColor(164) \'背景颜色 Text18.Style.TextColor=Color.FromKnownColor(35) \'字体颜色 Text18.Width=30 \'宽度 Text18.Height=8 \'高度 Text18.X=26.5 \'水平位置 Text18.Y=0 \'垂直位置
Dim ra As new prt.RenderArea ra.children.add(text8) ra.children.add(text18) doc.body.Children.add(ra)
Dim tb As Table \'定义一个数据表 Dim cn As String \'定义一个Grid Dim ColNames As String() \'定义一个数据表列数组 Dim Col_lst As new List(of String) \'列集合 Dim c As Integer Dim iw As Integer Dim ar1 As String Dim li As Integer Dim Grid9 As New prt.RenderTable \'定义一个报表数据表对象 tb= Tables("weixindanhao.weixin") \'定义一个数据表 cn="name|30|shuliang|10|price|20" \'显示列 ColNames=cn.split("|") \'显示列转换 iw=0 For c = 0 To ColNames.Length -1 If c Mod 2=0 Then iw+=ColNames(c+1) Grid9.Cells(0,c/2).Text = ColNames(c) Grid9.Cols(c/2).Width = ColNames(c+1) If tb.DataTable.datacols(ColNames(c)).IsDate Then If ColNames(c).contains("-") Then Grid9.Cells(1, c/2).Text ="[Format(Fields!"&ColNames(c)&".Value,""yyyy-MM-dd"")]" \'日期列调整 Else Grid9.Cells(1, c/2).Text ="[Format(Fields!"&ColNames(c)&".Value,""yyyy/MM/dd"")]" \'日期列调整 End If Else Grid9.Cells(1, c/2).Text ="[Fields!" & ColNames(c) & ".Value]" \'设置绑定表达式 End If End If Next Grid9.RowGroups(1,1).DataBinding.DataSource = BindTables("weixindanhao.weixin") \'将第二行绑定到订单表 Grid9.Width=iw \'自动宽度 Grid9.Style.TextAlignHorz=prt.AlignHorzEnum.Left \'文本对齐,水平 Grid9.Style.TextAlignVert=prt.AlignVertEnum.Top \'文本对齐,垂直 Grid9.Style.Font=New System.Drawing.Font("Gulim",9,0,3,1,False) \'文本字体 Grid9.Style.BackColor=Color.FromKnownColor(164) \'背景颜色 Grid9.Style.TextColor=Color.FromKnownColor(35) \'字体颜色 Grid9.CellStyle.Spacing.All=0.5 \'单元格文本内距 Grid9.RowGroups(0,tb.HeaderRows).Style.TextAlignHorz=prt.AlignHorzEnum.Left \'文本对齐,水平 Grid9.RowGroups(0,tb.HeaderRows).Style.TextAlignVert=prt.AlignVertEnum.Top \'文本对齐,垂直 Grid9.RowGroups(0,tb.HeaderRows).Style.Font=New System.Drawing.Font("宋体",9.5,0,3,134,False) \'文本字体 Grid9.RowGroups(0,tb.HeaderRows).Style.BackColor=Color.FromKnownColor(164) \'背景颜色 Grid9.RowGroups(0,tb.HeaderRows).Style.TextColor=Color.FromKnownColor(35) \'字体颜色 Grid9.RowGroups(0,tb.HeaderRows).CellStyle.Spacing.All=0.5 \'单元格文本内距 Grid9.Style.GridLines.All = New Prt.LineDef("0.2",Color.FromKnownColor(35)) \'所有网格线 Grid9.Style.GridLines.Vert = New Prt.LineDef("0.2",Color.FromKnownColor(35)) \'所有网格线 Grid9.Style.GridLines.Horz = New Prt.LineDef("0.2",Color.FromKnownColor(35)) \'所有网格线 Dim LineLine3 As New prt.LineDef(1,Color.FromKnownColor(35),DashStyle.Solid) Dim Line3 As New prt.RenderLine(8,10,76,10, LineLine3) \'定义一个线段对象 Dim LineLine4 As New prt.LineDef(1,Color.FromKnownColor(35),DashStyle.Solid) Dim Line4 As New prt.RenderLine(9.75,30,75.75,30, LineLine4) \'定义一个线段对象 Dim txt As new prt.RenderText txt.text = "false" txt.x = 10 txt.y = 20 ra = new prt.RenderArea ra.children.add(line3) ra.children.add(txt) ra.children.add(line4)
Doc.Body.Children.Add(Grid9) \'将数据表加入到报表 Doc.Body.Children.Add(ra) \'将线条加入到报表 doc.Preview() \'预览
|