以文本方式查看主题
- Foxtable(狐表) (http://foxtable.com/bbs/index.asp)
-- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2)
---- 专业报表生成行号例 (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=21848)
|
-- 作者:bm
-- 发布时间:2012/7/26 6:11:00
-- 专业报表生成行号例
如题。看了一晚上帮助。没找到。
那位高手帮忙。
Dim doc As New PrintDoc \'定义一个新报表 Dim rt As New prt.RenderTable \'定义一个新表格 Dim tb as Table = Tables("订单") Dim ColNames As New List(Of String) For Each cl As Col In tb.Cols \'排除隐藏列 If cl.Visible Then ColNames.Add(cl.Name) End If Next rt.Width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和 rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页 rt.Style.Font = tb.Font For c As Integer = 0 To ColNames.Count - 1 \'逐列设置和填入内容 rt.Cells(0,c).Text = ColNames(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 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.Preview()
|
-- 作者:bm
-- 发布时间:2012/7/26 11:47:00
-- 帮帮我吧
帮帮我吧
|
-- 作者:狐狸爸爸
-- 发布时间:2012/7/26 12:17:00
--
带行号的打印表:
Dim doc As New PrintDoc \'定义一个新报表 Dim rt As New prt.RenderTable \'定义一个新表格 Dim tb As Table = Tables("订单") Dim ColNames As New List(Of String) For Each cl As Col In tb.Cols \'排除隐藏列 If cl.Visible Then ColNames.Add(cl.Name) End If Next rt.Width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和 rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页 rt.Style.Font = tb.Font For c As Integer = 0 To ColNames.Count - 1 \'逐列设置和填入内容 rt.Cells(0,c+1).Text = ColNames(c) \'列名作为标题 rt.Cells(0,c+1).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'标题内容水平居中 rt.Cols(c+1).Width = tb.Cols(ColNames(c)).PrintWidth \'列宽等于实际列宽 If tb.Cols(ColNames(c)).IsNumeric OrElse tb.Cols(ColNames(c)).IsDate Then \'如果是数值或日期列 rt.Cols(c+1).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'数据水平靠右 End If For r As Integer = 0 To tb.Rows.Count -1 \'开始填入该列内容 rt.Cells(r + 1, c+1).Text = tb.Rows(r)(ColNames(c)) Next Next rt.cols(0).Width = 10 For i As Integer = 0 To tb.Rows.Count - 1 rt.Cells(i+1,0).text = i + 1 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.Preview()
|
-- 作者:bm
-- 发布时间:2012/7/26 12:30:00
--
太感谢了
|
-- 作者:狐狸爸爸
-- 发布时间:2012/7/26 14:54:00
--
下面的更好理解:
Dim doc As New PrintDoc \'定义一个新报表 Dim rt As New prt.RenderTable \'定义一个新表格 Dim tb As Table = Tables("订单") Dim ColNames As New List(Of String) For Each cl As Col In tb.Cols \'排除隐藏列 If cl.Visible Then ColNames.Add(cl.Name) End If Next rt.Width = "Auto" \'表格宽度为自动,也就是等于各列设置宽度之和 rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded \'表格宽度超出页宽时,可以水平换页 rt.Style.Font = tb.Font For c As Integer = 0 To ColNames.Count - 1 \'逐列设置和填入内容 rt.Cells(0,c).Text = ColNames(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 Next rt.Cols.Insert(0) rt.cols(0).Width = 10 For i As Integer = 0 To tb.Rows.Count - 1 rt.Cells(i+1,0).text = i + 1 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.Preview()
|