-- 作者:99473593
-- 发布时间:2015/5/27 19:12:00
-- [求助]请帮改下,专业报表依次打印图片代码
此主题相关图片如下:20150527.jpg
代码如下:
\'开始 Dim Filter As String = "1=1" \'设置报表名称主标题 Dim ym As New prt.RenderTable ym.Cells(0,0).text = "卜卜丫饰品发货单" ym.Cells(0,0).SpanCols = 12 \'合并第一行全部单元格,用于显示主标题 ym.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'主标题居中 ym.Cells(0,0).Style.Font = New Font("宋体", 20, FontStyle.Bold) \'设置主标题字体 ym.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white) \'去掉第一行的网格线 ym.Style.Spacing.Bottom = 5 \'和下面的对象(表格)距离3毫米 ym.CellStyle.Spacing.Bottom = 0.5 \'底端内容缩进0.5毫米 \'设置报表附标题 ym.Cells(1,0).text = "店面编号:" & Tables("DingDanMingXi").Compute("Max(DingDan_KeHuBianHao)")\'获取筛选结果的最小最大日期 ym.Cells(1,0).SpanCols = 5 \'合并第一行全部单元格,用于显示主标题 ym.Cells(1,6).text = "页码:第[PageNo]/[PageCount]页" ym.Cells(1,6).SpanCols = 5 \'合并第一行全部单元格,用于显示主标题 ym.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'主标题居中 ym.Cells(1,6).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'主标题居中 ym.Cells(1,0).Style.Font = New Font("宋体", 10, FontStyle.Bold) \'设置主标题字体 ym.Cells(1,6).Style.Font = New Font("宋体", 10, FontStyle.Bold) \'设置主标题字体 ym.Rows(1).Style.Borders.All = New prt.LineDef("0mm", Color.white) \'去掉第一行的网格线 ym.Style.Spacing.Bottom = 2 \'和下面的对象(表格)距离3毫米 ym.CellStyle.Spacing.Bottom = 0.5 \'底端内容缩进0.5毫米
\'设置排序条件 Tables("DingDanMingXi").Sort = "DingDanMingXi_TianMaHao" \'排序列用 \'输出报表 Dim doc As New PrintDoc \'定义一个新报表 Dim rt As prt.RenderTable \'定义一个表格 Dim tb As Table = Tables("DingDan.DingDanMingXi") \'指定数据来源 \'指定报表显示列 Dim aPageCount As Integer = 15 \'每页打印的行数 Dim ColNames() As String = {"DingDanMingXi_TianMaHao","DingDanMingXi_ShangPinMingCheng","DingDanMingXi_ShuLiang","DingDanMingXi_PiFaJia","DingDanMingXi_PiFaJinE","DingDanMingXi_LingShouJia","DingDanMingXi_LinShouJinE",DingDanMingXi_TuPian} Dim sum1 As Double = 0 Dim sum2 As Double = 0 Dim sum3 As Double = 0 Dim sum1z As Double = 0 Dim sum2z As Double = 0 Dim sum3z As Double = 0 For i As Integer = 0 To tb.Rows.Count - 1 If i Mod aPageCount = 0 Then \'换页 If i <> 0 Then \'统计 rt.Cells(aPageCount + 1, 0).Text = "小计" rt.Cells(aPageCount + 1, 3).Text = sum1 rt.Cells(aPageCount + 1, 5).Text = sum2 rt.Cells(aPageCount + 1, 7).Text = sum3 sum1 = 0 sum2 = 0 sum3 = 0 End If rt = new prt.RenderTable \'定义一个新表格 rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页 rt.Style.Font = tb.Font rt.Style.Gridlines.All = New prt.LineDef(Color.Gray) rt.CellStyle.Spacing.All = 2 \'单元格内距设为0.5毫米 rt.Rows(0).Style.BackColor = Color.lightGray rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中 rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All \'利用行组,将第一行设为表头 rt.BreakBefore = prt.BreakEnum.Page rt.Cols(0).Width = 8 \'设定报表的列数 For j As Integer = 0 To colNames.Length - 1 \'逐列设置和填入内容 rt.Cells(0, j+1).Text = colNames(j) \'Caption Names rt.Cols(j+1).Width = tb.Cols(colNames(j)).PrintWidth \'列宽等于实际列宽 If tb.Cols(colNames(j)).IsNumeric OrElse tb.Cols(colNames(j)).IsDate Then \'如果是数值或日期列 rt.Cols(j+1).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右 rt.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'设置第1列内容居中 rt.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'设置第2列内容居中 rt.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'设置第3列内容居中 rt.Cols(3).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'设置第4列内容居中 rt.Cols(4).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'设置第5列内容居中 rt.Cols(5).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'设置第6列内容居中 rt.Cols(6).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'设置第7列内容居中 rt.Cols(7).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'设置第8列内容居中 rt.Cols(0).Width = 9 rt.Cells(0,0).Text = "序号" rt.Cols(1).Width = 10 rt.Cells(0,1).Text = "条码号" rt.Cols(2).Width = 32 rt.Cells(0,2).Text = "商品名称" rt.Cols(3).Width = 10 rt.Cells(0,3).Text = "数量" rt.Cols(4).Width = 10 rt.Cells(0,4).Text = "批发价" rt.Cols(5).Width = 10 rt.Cells(0,5).Text = "批发金额" rt.Cols(6).Width = 10 rt.Cells(0,6).Text = "零售价" rt.Cols(7).Width = 10 rt.Cells(0,7).Text = "零售金额" rt.Cols(8).Width = 10 rt.Cells(0,8).Text = "图片" End If rt.Cells(0, j+1).Style.TextAlignHorz = prt.AlignHorzEnum.Center Next doc.Body.Children.Add(rt) \'将表格加入到报表 End If For j As Integer = 0 To colNames.Length - 1 rt.Cells(i Mod aPageCount + 1, 0).Text = i + 1 rt.Cells(i Mod aPageCount + 1, j+1).Text = tb.Rows(i)(colNames(j)) Next sum1 += tb.Rows(i)("DingDanMingXi_ShuLiang") sum2 += tb.Rows(i)("DingDanMingXi_PiFaJinE") sum3 += tb.Rows(i)("DingDanMingXi_LingShouJinE") sum1z += tb.Rows(i)("DingDanMingXi_ShuLiang") sum2z += tb.Rows(i)("DingDanMingXi_PiFaJinE") sum3z += tb.Rows(i)("DingDanMingXi_LingShouJinE") Next For j As Integer = tb.Rows.Count Mod aPageCount To aPageCount rt.Cells(j, 0).Text = j Next rt.Cells(aPageCount + 1, 0).Text = "小计" rt.Cells(aPageCount + 1, 3).Text = sum1 rt.Cells(aPageCount + 1, 5).Text = sum2 rt.Cells(aPageCount + 1, 7).Text = sum3 rt.Cells(aPageCount + 2, 0).Text = "总计" rt.Cells(aPageCount + 2, 3).Text = sum1z rt.Cells(aPageCount + 2, 5).Text = sum2z rt.Cells(aPageCount + 2, 7).Text = sum3z \'报表版面设置 doc.PageSetting.Landscape = False \'True为横向打印,False为竖向 Doc.PageSetting.LeftMargin = 15 \'设置左边距 Doc.PageSetting.RightMargin = 15 \'设置右边距 Doc.PageSetting.TopMargin = 10 \'设置上边距 Doc.PageSetting.BottomMargin = 0 \'设置下边距 doc.PageSetting.PaperKind = 9 \'纸张类型改为A4 Dim x As Integer = 0 \'定义水平偏移参数 Dim y As Integer = 0 \'定义垂直偏移参数 \'如果需要分栏打印,请加上下面两行 \'doc.Columns.Add() \'doc.Columns.Add()
\'设置页脚 Dim yj As New prt.RenderTable yj.Cells(1,3).Text = Date.Today yj.Cells(1,2).Text = "打印日期:" yj.Cells(1,1).Text = "第[PageNo]/[PageCount]页" yj.Style.Font = New Font("宋体", 10 ) \'设置文本对象的字体 yj.Style.Spacing.Bottom = 5 \'和下面的对象(表格)距离3毫米 yj.Cols(0).Style.TextAlignHorz = prt.AlignHorzEnum.Left yj.Cols(1).Style.TextAlignHorz = prt.AlignHorzEnum.Center yj.Cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.right yj.CellStyle.Spacing.Bottom = 0.5 \'底端内容缩进0.5毫米 Doc. PageFooter = yj \'作为页眉使用 Doc.PageHeader = ym \'作为页眉使用 doc.Preview()
[此贴子已经被作者于2015/5/27 19:15:36编辑过]
|
-- 作者:大红袍
-- 发布时间:2015/5/27 19:42:00
--
For j As Integer = 0 To colNames.Length - 1 rt.Cells(i Mod aPageCount + 1, 0).Text = i + 1 rt.Cells(i Mod aPageCount + 1, j+1).Text = tb.Rows(i)(colNames(j)) Next
改成
For j As Integer = 0 To colNames.Length - 1 rt.Cells(i Mod aPageCount + 1, 0).Text = i + 1 If ColNames(j) = "DingDanMingXi_TuPian" Then Network.DownloadFile(tb.Rows(i)(colNames(j)), ProjectPath & "temp.jpg") rm.Image = GetImage(ProjectPath & "temp.jpg") \'请改为实际的图标名称和路径 rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center \'图片水平居中 rm.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center \'图片垂直居中 rm.Style.ImageAlign.StretchHorz = False \'禁止水平方向扩展图片 rm.Style.ImageAlign.StretchVert = False \'禁止垂直方向扩展图片 rt.Cells(i Mod aPageCount + 1, j+1).RenderObject = rm Else rt.Cells(i Mod aPageCount + 1, j+1).Text = tb.Rows(i)(colNames(j)) End If Next
|
-- 作者:大红袍
-- 发布时间:2015/5/28 14:59:00
--
不会弄,就上传具体例子。
For j As Integer = 0 To colNames.Length - 1 rt.Cells(i Mod aPageCount + 1, 0).Text = i + 1 If ColNames(j) = "DingDanMingXi_TuPian" Then Network.DownloadFile(tb.Rows(i)(colNames(j)), ProjectPath & "下载的图片" & tb.Rows(i)("商品条码") & ".jpg","" ,"" ,True, 100000, True) Dim rm As new prt.RenderImage rm.Image = GetImage(ProjectPath & "temp.jpg") \'请改为实际的图标名称和路径 rm.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center \'图片水平居中 rm.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center \'图片垂直居中 rm.Style.ImageAlign.StretchHorz = False \'禁止水平方向扩展图片 rm.Style.ImageAlign.StretchVert = False \'禁止垂直方向扩展图片 rt.Cells(i Mod aPageCount + 1, j+1).RenderObject = rm Else rt.Cells(i Mod aPageCount + 1, j+1).Text = tb.Rows(i)(colNames(j)) End If Next
|