以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 打印 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=80935) |
|
-- 作者:gcc123 -- 发布时间:2016/2/13 9:57:00 -- 打印
|
|
-- 作者:Hyphen -- 发布时间:2016/2/13 10:41:00 -- 手动合计,参考:http://www.foxtable.com/help/topics/1240.htm |
|
-- 作者:gcc123 -- 发布时间:2016/2/13 15:55:00 -- Dim doc As New PrintDoc \'定义一个新报表 doc.PageSetting.Landscape = True \'横向打印 Dim rt As New prt.RenderTable \'定义一个新表格 Dim tb As Table = Tables("应收查询") Dim ColNames As String() = New String(){"日期", "托运单位", "货物名称", "起点", "终点", "回单", "吨位2", "价格2", "吊杂费", "扣款2", "金额", "车号", "备注"} Dim PrintColNames As String() = New String(){"日期", "托运单位", "货物名称", "起点", "终点", "回单", "吨位", "价格", "吊杂费", "扣款", "金额", "车号", "备注"} rt.Width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和 rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页 rt.Style.Font = tb.Font Dim D As prt.RenderText \'定义一个文本对象 For i As Integer = 1 To 1 D = New prt.RenderText D.Style.TextIndent = 9 \'首行缩进9毫米 D.Style.Spacing.Top = 5 \'每段间隔5毫米 D.Style.LineSpacing = 1 \'1.5倍行距 doc.Body.Children.Add(D) \'将文本对象加入到报表 Next \'设置页眉 D = New prt.RenderText \'设置文本对象的内容 D.Text = "第[PageNo]页,共[PageCount]页" \'设置文本内容 D.Style.TextAlignHorz = prt.AlignHorzEnum.Right \'靠右对齐 D.Style.Borders.Bottom = New prt.LineDef(0.3, Color.Green) \'设置底边框 D.Style.Padding.Bottom = 0.5 \'底端内容缩进0.5毫米 D.Style.FontSize = 8 \'字体大小为8磅 Doc.PageHeader = D \'作为页眉使 Dim rs As New prt.RenderText() rs.Text = "应收明细账" \'设置文本对象的内容 rs.Style.Font = New Font("宋体", 24 , FontStyle.Bold) \'设置文本对象的字体 rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'文本内容水平居中 doc.Body.Children.Add(rs) \'将文本对象加入到表格中 For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内容 rt.Cells(0,c).Text = PrintColNames(c) \'列名作为标题 rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中 rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth \'列宽等于实际列宽 If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then \'如果是数值或日期列 rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右 End If For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容 rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c)) Next If ColNames(c) = "回单" Then For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容 rt.Cells(r + 1, c).Text = "回单" Next Else For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容 rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c)) Next End If Next rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线 rt.CellStyle.Spacing.All = 0.5 \'单元格内距设为0.5毫米 rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中 rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All \'利用行组,将第一行设为表头. doc.Body.Children.Add(rt) \'将表格加入到报表 \'如果需要分栏打印,请加上下面两行 \'doc.Columns.Add() \'doc.Columns.Add() doc.Preview() 老师看看 以上的代码有没有重复的?另外最后的合计行写什么代码能加入到报表中?
|
|
-- 作者:Hyphen -- 发布时间:2016/2/13 16:18:00 -- Dim doc As New PrintDoc \'定义一个新报表 doc.PageSetting.Landscape = True \'横向打印 Dim rt As New prt.RenderTable \'定义一个新表格 Dim tb As Table = Tables("应收查询") Dim ColNames As String() = New String(){"日期", "托运单位", "货物名称", "起点", "终点", "回单", "吨位2", "价格2", "吊杂费", "扣款2", "金额", "车号", "备注"} Dim PrintColNames As String() = New String(){"日期", "托运单位", "货物名称", "起点", "终点", "回单", "吨位", "价格", "吊杂费", "扣款", "金额", "车号", "备注"} rt.Width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和 rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页 rt.Style.Font = tb.Font Dim D As prt.RenderText \'定义一个文本对象 For i As Integer = 1 To 1 D = New prt.RenderText D.Style.TextIndent = 9 \'首行缩进9毫米 D.Style.Spacing.Top = 5 \'每段间隔5毫米 D.Style.LineSpacing = 1 \'1.5倍行距 doc.Body.Children.Add(D) \'将文本对象加入到报表 Next \'设置页眉 D = New prt.RenderText \'设置文本对象的内容 D.Text = "第[PageNo]页,共[PageCount]页" \'设置文本内容 D.Style.TextAlignHorz = prt.AlignHorzEnum.Right \'靠右对齐 D.Style.Borders.Bottom = New prt.LineDef(0.3, Color.Green) \'设置底边框 D.Style.Padding.Bottom = 0.5 \'底端内容缩进0.5毫米 D.Style.FontSize = 8 \'字体大小为8磅 Doc.PageHeader = D \'作为页眉使 Dim rs As New prt.RenderText() rs.Text = "应收明细账" \'设置文本对象的内容 rs.Style.Font = New Font("宋体", 24 , FontStyle.Bold) \'设置文本对象的字体 rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'文本内容水平居中 doc.Body.Children.Add(rs) \'将文本对象加入到表格中 For c As Integer = 0 To ColNames.Length - 1 \'逐列设置和填入内容 rt.Cells(0,c).Text = PrintColNames(c) \'列名作为标题 rt.Cells(0,c).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中 rt.Cols(c).Width = tb.Cols(ColNames(c)).PrintWidth \'列宽等于实际列宽 If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then \'如果是数值或日期列 rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右 End If \'For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容 \'rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c)) \'Next If ColNames(c) = "回单" Then For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容 rt.Cells(r + 1, c).Text = "回单" Next Else For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容 rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c)) Next End If Next rt.Cells(rt.Rows.Count,0).Text = "合计" rt.Cells(rt.Rows.Count,6).Text = Tables("应收查询").Compute("Sum(吨位2)") rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线 rt.CellStyle.Spacing.All = 0.5 \'单元格内距设为0.5毫米 rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中 rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All \'利用行组,将第一行设为表头. doc.Body.Children.Add(rt) \'将表格加入到报表 \'如果需要分栏打印,请加上下面两行 \'doc.Columns.Add() \'doc.Columns.Add() doc.Preview() |
|
-- 作者:gcc123 -- 发布时间:2016/2/13 16:58:00 -- rt.Cells(rt.Rows.Count,0).Text = "合计" rt.Cells(rt.Rows.Count,6).Text = Tables("应收查询").Compute("Sum(吨位2)") rt.Cells(rt.Rows.Count,8).Text = Tables("应收查询").Compute("Sum(吊杂费)") rt.Cells(rt.Rows.Count,9).Text = Tables("应收查询").Compute("Sum(扣款2)") rt.Cells(rt.Rows.Count,10).Text = Tables("应收查询").Compute("Sum(扣款)") rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) \'灰色网格线 rt.CellStyle.Spacing.All = 0.5 \'单元格内距设为0.5毫米 rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中 rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All \'利用行组,将第一行设为表头. doc.Body.Children.Add(rt) \'将表格加入到报表 我想实现的是 最后合计行 所需要合计的几列数据都是合计行同一行中?现在打印输出的是几列合计数据都是按梯形排列的 不是在同一行
|
|
-- 作者:Hyphen -- 发布时间:2016/2/13 17:04:00 -- Dim count = rt.Rows.Count rt.Cells(count ,0).Text = "合计" rt.Cells(count ,6).Text = Tables("应收查询").Compute("Sum(吨位2)") rt.Cells(count ,8).Text = Tables("应收查询").Compute("Sum(吊杂费)") rt.Cells(count ,9).Text = Tables("应收查询").Compute("Sum(扣款2)") rt.Cells(count ,10).Text = Tables("应收查询").Compute("Sum(扣款)")
|
|
-- 作者:gcc123 -- 发布时间:2016/2/13 17:15:00 -- Dim D As prt.RenderText \'定义一个文本对象 For i As Integer = 1 To 1 D = New prt.RenderText D.Style.TextIndent = 9 \'首行缩进9毫米 D.Style.Spacing.Top = 5 \'每段间隔5毫米 D.Style.LineSpacing = 1 \'1.5倍行距 doc.Body.Children.Add(D) \'将文本对象加入到报表 Next \'设置页眉 D = New prt.RenderText \'设置文本对象的内容 D.Text = "第[PageNo]页,共[PageCount]页" \'设置文本内容 D.Style.TextAlignHorz = prt.AlignHorzEnum.Right \'靠右对齐 D.Style.Borders.Bottom = New prt.LineDef(0.3, Color.Green) \'设置底边框 D.Style.Padding.Bottom = 0.5 \'底端内容缩进0.5毫米 D.Style.FontSize = 8 \'字体大小为8磅 Doc.PageHeader = D \'作为页眉使 Dim rs As New prt.RenderText() rs.Text = "应收明细账" \'设置文本对象的内容 rs.Style.Font = New Font("宋体", 24 , FontStyle.Bold) \'设置文本对象的字体 rs.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'文本内容水平居中 doc.Body.Children.Add(rs) \'将文本对象加入到表格中 如何把 应收明细账 标题 移动到页眉绿色横线之上 ? 报表在生成的过程中能不能自动按照纸张大小 来自动调整行列之间的间距? |
|
-- 作者:Hyphen -- 发布时间:2016/2/13 17:47:00 -- 用表格作为页眉:http://www.foxtable.com/help/topics/1221.htm |
|
-- 作者:gcc123 -- 发布时间:2016/2/13 18:20:00 -- 回复:(Hyphen)用表格作为页眉:http://www.foxtabl... rx.Cells(0,0).Text = Date.Today 日期前边能不能加上 打印日期 这几个字?
|
|
-- 作者:大红袍 -- 发布时间:2016/2/14 -- rx.Cells(0,0).Text = "打印日期:" & Date.Today
|