以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 专业报表表头标题 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=189330) |
||||
-- 作者:denghui69986 -- 发布时间:2023/11/25 9:53:00 -- 专业报表表头标题 怎么在表上添加表头标题 此主题相关图片如下:表头截图.png 下面打印按键代码,页边距也没找到方法调整,老师帮忙看看,谢谢! Dim doc As New PrintDoc Dim rt As New Prt.RenderTable Dim rx As prt.RenderText Dim cnt As Integer Dim tbl As Table = Tables("总工资完工表_Table1") Dim drs As List(Of DataRow) Dim pds As List(Of String) = tbl.DataTable.GetValues("输入日期", tbl.Filter) rt.Style.GridLines.All = New prt.LineDef(0.1, Color.LightGray) rt.CellStyle.Spacing.All = 1 rt.Style.FontSize = 10.5 \'字体大小为16磅 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中排列 rt.Rows(0).Style.FontBold = True \'字体加粗 rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中排列 rt.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Center \'内容垂直居中 rt.Rows(0).Style.FontSize = 11 \'字体大小为16磅 For c As Integer = 0 To tbl.Cols.Count - 1 \'生成列标题 rt.Cells(0, c).Text = tbl.Cols(c).Name rt.Rows(0).Height = 7 rt.Cols(2).Width = 30 rt.Cols(3).Width = 40 rt.Cols(4).Width = 30 rt.Cols(5).Width = 45 rt.Cols(6).Width = 30 rt.Cols(7).Width = 40 rt.Cols(8).Width = 30 rt.Cols(9).Width = 40 rt.Cols(10).Width = 30 rt.Cols(11).Width = 35 rt.Cols(12).Width = 45 rt.Cols(13).Width = 30 rt.Cols(14).Width = 30 Next For Each pd As String In pds \'分产品打印 If tbl.Filter > "" Then drs = tbl.DataTable.Select("输入日期 = \'" & pd & "\' And " & tbl.Filter) Else drs = tbl.DataTable.Select("输入日期 = \'" & pd & "\'") End If For Each dr As DataRow In drs \'逐行打印此产品的订单 cnt = rt.Rows.Count For c As Integer = 0 To tbl.Cols.Count - 1 rt.Cells(cnt, c).Text = dr(tbl.Cols(c).Name) Next Next cnt = rt.Rows.Count rt.Cells(cnt, 1).Text = pd & "合计 " \'打印产品的小计 rt.Cells(cnt, 0).style.TextAlignHorz = prt.AlignHorzEnum.right \'水平居中排列 rt.Cells(cnt, 0).Style.FontBold = True \'字体加粗 rt.Cells(cnt, 0).Style.FontSize = 10.5 \'大体大小为16磅 rt.Cells(cnt, 2).Style.FontBold = True \'字体加粗 rt.Cells(cnt, 2).Style.FontSize = 10.5 \'大体大小为16磅 rt.Cells(cnt, 3).Style.FontBold = True \'字体加粗 rt.Cells(cnt, 3).Style.FontSize = 10.5 \'大体大小为16磅 rt.Cells(cnt, 0).SpanCols = 2 \'第5行第2个单元格向右合并3列(用于显示地址) rt.Cells(cnt, 3).Text = tbl.compute("Sum(计件工资)", "输入日期 = \'" & pd & "\'") & "元" rt.Cells(cnt, 4).Text = tbl.compute("Sum(计时金额)", "输入日期 = \'" & pd & "\'") & "元" Next doc.Body.Children.Add(rt) doc.preview() |
||||
-- 作者:有点蓝 -- 发布时间:2023/11/25 10:22:00 -- 标题参考:http://www.foxtable.com/webhelp/topics/2735.htm,或者:http://www.foxtable.com/webhelp/topics/1212.htm |
||||
-- 作者:denghui69986 -- 发布时间:2023/11/27 10:45:00 -- 第一次做外部数据窗口专业报表,尝试两天还是没做好,框架表头边距都可以了,就是内容带不进,表里统计(生产金额和计件金额,统计)框架出来就是数据不进表里面。 此主题相关图片如下:专业报表截图.png 此主题相关图片如下:专业报表求和.png 专业报表代码下面这些,老师帮忙看看问题在那里,感谢! Dim doc As New PrintDoc() \'定义一个报表 \'doc.PageSetting.Width = 210 \'纸张宽度为210毫米 \'doc.PageSetting.Height = 120 \'纸张高度为120毫米 \'doc.AutoRotate = False \'禁止自动旋转打印内容 \'doc.PageSetting.Landscape = True \'横向打印 Doc.PageSetting.LeftMargin = 25 \'设置左边距 Doc.PageSetting.RightMargin = 15 \'设置右边距 Doc.PageSetting.TopMargin = 0 \'设置上边距 Doc.PageSetting.BottomMargin = 0 \'设置下边距 Dim rt As New prt.RenderTable() \'定义一个表格对象 rt.Style.GridLines.All = New prt.LineDef \'将网格线类型设为默认类型 rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中 rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'垂直居中 rt.Style.Spacing.Top = 4 \'表格和前面对象的垂直间隔为4毫米 rt.Style.Spacing.Bottom = 10 \'表和和后续对象的垂直间隔为10毫米 rt.Style.Spacing.All = 1 \'报表所有网格线为1mm rt.y = "20mm" rt.Style.GridLines.All = New Prt.LineDef(0.5, Color.Black) rt.Style.GridLines.Horz = New Prt.LineDef(Color.Black) rt.Style.GridLines.Vert = New Prt.LineDef(Color.Black) rt.Rows.Count = 1 \'设置行数,需要注意的是,新增报表总行数设置为1行 rt.Cols.Count = 7 \'设置列数,列数根据您的需要 rt.cells(rt.Rows.Count - 1, 0).Text = "长优日用制品有限公司1#员工月工序汇总算单"\'因为总行数为1行,所以首次设置内容的时候,引用行位置为rt.Rows.Count - 1 rt.Rows(rt.Rows.Count - 1).Height = 13 & "mm" \'设置首行高度为13mm rt.Rows(rt.Rows.Count - 1).Style.GridLines.All = New Prt.LineDef(0, Color.Black) \'设置首行所有网格线为0——无网格线 rt.rows(rt.Rows.Count - 1).Style.Font = New Font("隶书", 18, FontStyle.bold) \'设置文本对象的字体 rt.Cells(rt.Rows.Count - 1, 0).SpanCols = 7 \'第1行第所有单元格为一个完整单元格。 rt.cells(rt.Rows.Count, 0).Text = "部门或姓名:" & e.Form.Controls("ComboBox1").Value & "结算清单" \'关键在于上面这一行,这里设置内容引用行位置的时候,直接rt.Rows.Count,这样专业报表也就自动增加了1行,因为引用位置没有减一,也就是抓住了专业报表设置内容自动增加行的特性。 rt.Cells(rt.Rows.Count - 1, 0).SpanCols = 7 \'第2行第1个单元格向右合并7列, \'而到了这里,直接给最后行设置内容而不需要增加行,所以在这里必须减1,所以引用行位置因为rt.Rows.Count-1,再往下面的代码我就不需要解释,大家只需要区别需要增加行时,引用行位置的为rt.Rows.Count,不需要增加行的时候为rt.Rows.Count-1,这样您在设计报表的过程中您可以从任意位置插入行,也可以从任意位置嵌套多级分组统计行,您只需要在插入相应代码即可。 rt.rows(rt.Rows.Count - 1).Style.Font = New Font("黑体", 12) \'设置文本对象的字体 rt.Rows(rt.Rows.Count - 1).Height = 6 & "mm" rt.rows(rt.Rows.Count - 1).Style.TextAlignHorz = prt.AlignHorzEnum.left \'水平居左 rt.Rows(rt.Rows.Count - 1).Style.GridLines.left = New Prt.LineDef(0, Color.Black) rt.Rows(rt.Rows.Count - 1).Style.GridLines.Right = New Prt.LineDef(0, Color.Black) rt.cells(rt.Rows.Count, 0).Text = "序号" rt.cells(rt.Rows.Count - 1, 1).Text = "生产批号" rt.cells(rt.Rows.Count - 1, 2).Text = "型号" rt.cells(rt.Rows.Count - 1, 3).Text = "工序名称" rt.cells(rt.Rows.Count - 1, 4).Text = "生产金额" rt.cells(rt.Rows.Count - 1, 5).Text = "输入日期" rt.cells(rt.Rows.Count - 1, 6).Text = "备 注" rt.Rows(rt.Rows.Count - 1).Height = 12 & "mm" rt.rows(rt.Rows.Count - 1).Style.Font = New Font("宋体", 12, FontStyle.bold) \'设置文本对象的字体 rt.Rows(rt.Rows.Count - 1).Style.BackColor = Color.LightGray \'第一行背景颜色设为灰色. rt.rows(rt.Rows.Count - 1).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中 rt.RowGroups(0, 3).Header = prt.TableHeaderEnum.All \'将前三行作为表头. rt.Cols(0).Width = 12 & "mm" rt.Cols(1).Width = 35 & "mm" rt.Cols(2).Width = 16 & "mm" rt.Cols(3).Width = 60 & "mm" rt.Cols(4).Width = 40 & "mm" rt.Cols(5).Width = 30 & "mm" rt.Cols(6).Width = 20 & "mm" rt.cells(rt.Rows.Count, 0).text = "一、计件金额大写:" & CUMoney(DataTables("计件完工单_Table1").Compute("Sum(生产金额)", "姓名 = \'应付款\' and 班别 = \'" & e.Form.Controls("ComboBox1").Value & "\'")) & "(小写:" & format(DataTables("计件完工单_Table1").Compute("Sum(生产金额)", "姓名 = \'应付款\' and 班别 = \'" & e.Form.Controls("ComboBox1").Value & "\'"), "0.00") & "元)" rt.rows(rt.Rows.Count - 1).Style.TextAlignHorz = prt.AlignHorzEnum.left \'水平居左 rt.Cells(rt.Rows.Count - 1, 0).SpanCols = 7 \'第4行第1个单元格向右合并7列 rt.rows(rt.Rows.Count - 1).Style.Font = New Font("宋体", 12, FontStyle.bold) \'设置文本对象的字体 rt.Rows(rt.Rows.Count - 1).Height = 12 & "mm" Dim drs As List(Of DataRow) drs = DataTables("计件完工单_Table1").Select("姓名 = \'应付款\' and 班别 = \'" & e.Form.Controls("ComboBox1").Value & "\'") For i As Integer = 0 To drs.Count - 1 rt.cells(rt.Rows.Count, 0).text = Format(i + 1, "00") rt.cells(rt.Rows.Count - 1, 1).text = drs(i)("生产批号") rt.cells(rt.Rows.Count - 1, 2).text = drs(i)("型号") rt.cells(rt.Rows.Count - 1, 3).text = drs(i)("工序名称") rt.cells(rt.Rows.Count - 1, 4).text = format(drs(i)("生产金额"), "0.00") rt.cells(rt.Rows.Count - 1, 5).text = drs(i)("输入日期") rt.cells(rt.Rows.Count - 1, 6).text = drs(i)("备注") rt.Rows(rt.Rows.Count - 1).Height = 8 & "mm" rt.cells(rt.Rows.Count - 1, 3).Style.TextAlignHorz = prt.AlignHorzEnum.left \'水平居左 rt.cells(rt.Rows.Count - 1, 4).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'水平靠右 Next Dim y As Integer = DataTables("计件完工单_Table1").Compute("Sum(生产金额)", "姓名 " & e.Form.Controls("ComboBox1").Value & "\'") - DataTables("计件完工单_Table1").Compute("Sum(生产金额)", "姓名" & e.Form.Controls("ComboBox1").Value & "\'") If y > 0 Then rt.cells(rt.Rows.Count, 0).text = "二、应结余额大写:" & CUMoney(y) & "(小写:" & format(y, "0.00") & "元)" Else rt.cells(rt.Rows.Count, 0).text = "二、应结余额大写:负" & CUMoney( Math.Abs(y)) & "(小写:" & format(y, "0.00") & "元)" rt.cells(rt.Rows.Count - 1, 0).Style.BackColor = Color.red End If rt.Cells(rt.Rows.Count - 1, 0).SpanCols = 7 \'第N行第0个单元格向右合并7列,这里同样只知道为最后一行 rt.rows(rt.Rows.Count - 1).Style.TextAlignHorz = prt.AlignHorzEnum.left \'水平居左 rt.rows(rt.Rows.Count - 1).Style.Font = New Font("宋体", 12, FontStyle.bold) \'设置文本对象的字体 rt.Rows(rt.Rows.Count - 1).Height = 10 & "mm" rt.cells(rt.Rows.Count, 0).text = "备注" rt.rows(rt.Rows.Count - 1).Style.Font = New Font("宋体", 12, FontStyle.bold) \'设置文本对象的字体 rt.Cells(rt.Rows.Count - 1, 1).SpanCols = 6 \'第2行第2个单元格向右合并3列 rt.Rows(rt.Rows.Count - 1).Height = 20 & "mm" rt.cells(rt.Rows.Count, 0).text = " 审 核: 记 帐: 经手人: 年 月 日" rt.rows(rt.Rows.Count - 1).Style.Font = New Font("宋体", 12, FontStyle.bold) \'设置文本对象的字体 rt.Cells(rt.Rows.Count - 1, 0).SpanCols = 7 \'第N行第0个单元格向右合并7列,这里同样只知道为最后一行 rt.Rows(rt.Rows.Count - 1).Style.GridLines.All = New Prt.LineDef(0, Color.Black) rt.Rows(rt.Rows.Count - 1).Style.GridLines.top = New Prt.LineDef(0.5, Color.Black) rt.Rows(rt.Rows.Count - 1).Height = 15 & "mm" doc.Body.Children.Add(rt) \'将表格对象加入到报表中 Doc.Preview() \'预览报表 |
||||
-- 作者:有点蓝 -- 发布时间:2023/11/27 10:57:00 -- 请上传实例测试 |
||||
-- 作者:denghui69986 -- 发布时间:2023/11/27 17:16:00 -- 测试上传了,打印在窗口上面外部数据,主要数据带不进去,在测试里面有描述问题说明,老师帮忙看看,感谢! |
||||
-- 作者:有点蓝 -- 发布时间:2023/11/27 17:41:00 --
|
||||
-- 作者:denghui69986 -- 发布时间:2023/11/28 9:56:00 -- 感谢,终于可以,谢谢 |