Foxtable(狐表)用户栏目专家坐堂 → [求助] 报表生成


  共有2521人关注过本帖树形打印复制链接

主题:[求助] 报表生成

帅哥哟,离线,有人找我吗?
wangyinming
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:童狐 帖子:286 积分:2345 威望:0 精华:0 注册:2013/8/30 3:37:00
[求助] 报表生成  发帖心情 Post By:2020/5/2 12:04:00 [只看该作者]

现在是根据 Tables("print_A5")的行来生成报表的,
但是现在只能一条一条生成,希望可以批量生成(可以用辅助列或者复选框吗?)。
该如何写?

'''
Dim doc As New PrintDoc()  '定义一个报表

doc.PageSetting.Width = 90 '纸张宽度为100毫米
doc.PageSetting.Height = 60 '纸张高度为90毫米
Doc.PageSetting.LeftMargin = 0 '设置左边距
Doc.PageSetting.RightMargin = 0 '设置右边距
Doc.PageSetting.TopMargin = 0 '设置上边距
Doc.PageSetting.BottomMargin = 0 '设置下边距

Dim rt As New prt.RenderTable() '定义一个表格对象
Dim rx As prt.RenderText '定义一个文本对象
Dim CurRow As Row = Tables("print_A5").Current

'设置水印
rx = New prt.RenderText '设置文本对象的内容
rx.Text = CurRow("背番号") '设置文本内容
rx.Width = 80 '宽度
rx.Height = 50 '高度
rx.x = 13
rx.y = 18
'rx.Style.TextAngle = 45 '旋转45度
rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中对齐
rx.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中对齐
rx.Style.FontSize = 100 '字体大小为110磅
rx.Style.FontBold = True '字体加粗
rx.Style.TextColor = Color.LightGray '文本颜色为灰色
Doc.WaterMark = rx '作为水印使用

'指定行数?列数?列宽?行高
rt.Rows.Count = 9 '设置总行数
rt.Cols.Count = 6 '设置总列数
rt.Height = 60  '设置表格的高度为60毫米
rt.Width = 90 '设置表格的宽度为100毫米
'rt.Width = "Auto" '表格宽度为自动,

rt.Rows(0).Height = 3 '设置第1行的高度
rt.Rows(1).Height = 20 '设置第2行的高度
rt.Rows(2).Height = 3  '设置第3行的高度
rt.Rows(3).Height = 8 '设置第4行的高度
rt.Rows(4).Height = 5  '设置第5行的高度,剩余高度被平均分排到其他行
rt.Rows(5).Height = 8   '第5行的高度,剩余高度被平均分排到其他行
rt.Rows(6).Height = 3  '设置第5行的高度,剩余高度被平均分排到其他行
rt.Rows(7).Height = 8  '设置第5行的高度,剩余高度被平均分排到其他行
rt.Rows(8).Height = 8  '设置第5行的高度,剩余高度被平均分排到其他行

rt.Cols(0).Width = 17 '设置各列的宽度
rt.Cols(1).Width = 19
rt.Cols(2).Width = 19
rt.Cols(3).Width = 5
rt.Cols(4).Width = 22
rt.Cols(5).Width = 23

'设置合并单元格
rt.Cells(0,0).SpanCols = 5 '第1行第1个单元格向右合并5列
rt.Cells(0,5).SpanRows = 2 '第1行第6个单元格向下合并2行
rt.Cells(1,0).SpanCols = 5 '第2行第1个单元格向右合并5列
rt.Cells(2,0).SpanCols = 5 '第3行第1个单元格向右合并2列
rt.Cells(3,0).SpanCols = 5 '第4行第1个单元格向右合并4列
rt.Cells(4,0).SpanCols = 3 '第5行第1个单元格向右合并2列
rt.Cells(4,5).SpanRows = 2 '第5行第6个单元格向下合并2行
rt.Cells(4,3).SpanRows = 2 '第5行第4个单元格向下合并2行
rt.Cells(5,0).SpanCols = 3 '第6行第1个单元格向右合并2列
rt.Cells(6,1).SpanCols = 4 '第7行第2个单元格向右合并4列
rt.Cells(6,1).SpanCols = 4 '第7行第2个单元格向右合并4列
rt.Cells(7,1).SpanCols = 4 '第8行第2个单元格向右合并4列
rt.Cells(8,1).SpanCols = 4 '第9行第2个单元格向右合并4列
rt.Cells(6,0).SpanRows = 3 '第7行第1个单元格向下合并3行

'设置表格样式
rt.CellStyle.Spacing.All = 0 '单元格内容缩进1毫米
rt.Style.GridLines.All = New prt.Linedef '设置网格线
rt.Rows(0).Style.Borders.Bottom  = New prt.LineDef("0mm", Color.white) '去掉第1行下边框网格线
rt.Rows(2).Style.Borders.Bottom  = New prt.LineDef("0mm", Color.white) '去掉第3行下边框网格线
rt.Rows(4).Style.Borders.Bottom  = New prt.LineDef("0mm", Color.white) '去掉第5行下边框网格线
rt.Rows(6).Style.Borders.Bottom  = New prt.LineDef("0mm", Color.white) '去掉第7行下边框网格线
'rt.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Top '第0行内容靠上对齐


'下面很简单,指定每一个单元格的内容
'设置二维码位置左下角
Dim rm As  prt.RenderImage '定义一个图片对象
Dim Bar As New BarCodeBuilder
Bar.Symbology = Barpro.Symbology.QRCode
Bar.BarRatio = 0.3
Bar.QuietZoneWidth = 0
'Bar.BarHeight = 8
Bar.QRCodeModuleSize = 0.4 '(大小)
Doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight
bar.Code = CurRow("QRコードデータ")
rm = new prt.RenderImage
rm.Image = bar.GetImage
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(6,0).RenderObject =rm

'设置二维码位置右上角
Dim rm1 As  prt.RenderImage '定义一个图片对象
Dim Bar1 As New BarCodeBuilder
Bar1.Symbology = Barpro.Symbology.QRCode
Bar1.BarRatio = 0.3
Bar1.QuietZoneWidth = 0
'Bar.BarHeight = 8
Bar1.QRCodeModuleSize = 0.60   '(大小)

Doc.Stacking = prt.StackingRulesEnum.InlineLeftToRight
bar1.Code = CurRow("QRコードデータ")
rm1 = new prt.RenderImage
rm1.Image = bar1.GetImage
rm1.Style.ImageAlign.AlignHorz = prt.ImageAlignHorzEnum.Center '图片水平居中
rm1.Style.ImageAlign.AlignVert = prt.ImageAlignVertEnum.Center '图片垂直居中
rm1.Style.ImageAlign.StretchHorz = False '禁止水平方向扩展图片
rm1.Style.ImageAlign.StretchVert = False '禁止垂直方向扩展图片
rt.Cells(0,5).RenderObject =rm1


rt.Cells(0,0).Text = " 背番号"
rt.Cells(0,0).Style.FontSize = 7

rt.Cells(1,0).Text = CurRow("背番号")
rt.Cells(1,0).Style.FontSize = 50
rt.Cells(1,0).Style.FontBold = True '字体加粗
rt.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Cells(1,0).Style.TextAlignVert = prt.AlignVertEnum.Bottom  '垂直靠上

rt.Cells(2,0).Text= " お客様呼び番号"
rt.Cells(2,0).Style.FontSize = 7
rt.Cells(3,0).Text= " "& CurRow ("客先向け呼び番号")
rt.Cells(3,0).Style.FontSize = 18

rt.Cells(2,5).Text= " お客様背番号"
rt.Cells(2,5).Style.FontSize = 7
rt.Cells(3,5).Text= " "& CurRow ("客先背番号")
rt.Cells(3,5).Style.FontSize = 20

rt.Cells(4,0).Text= " ロットNo."
rt.Cells(4,0).Style.FontSize = 7
rt.Cells(5,0).Text=  CurRow ("管理号码")
rt.Cells(5,0).Style.FontSize = 20
rt.Cells(5,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Cells(5,0).Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中

rt.Cells(4,3).Text= "合 格"
rt.Cells(4,3).Style.FontSize = 10
rt.Cells(4,3).Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中

rt.Cells(4,4).Text= " "& CurRow ("工号")
rt.Cells(4,4).Style.FontSize = 8
'rt.Cells(4,4).Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Cells(4,4).Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中

rt.Cells(5,4).Text= CurRow ("生产日期")
rt.Cells(5,4).Style.FontSize = 10
rt.Cells(5,4).Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Cells(5,4).Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中

rt.Cells(4,5).Text= CurRow ("特記")
rt.Cells(4,5).Style.FontSize = 13
rt.Cells(4,5).Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Cells(4,5).Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中

rt.Cells(6,1).Text= " 呼び番号"
rt.Cells(6,1).Style.FontSize = 7
rt.Cells(7,1).Text= CurRow ("KSTEC呼び番号")
rt.Cells(7,1).Style.FontSize = 15

rt.Cells(6,5).Text= " 収容数"
rt.Cells(6,5).Style.FontSize = 7
rt.Cells(6,5).Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Cells(6,5).Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中

rt.Cells(7,5).Text= CurRow ("収容数")
rt.Cells(7,5).Style.FontSize = 20
rt.Cells(7,5).Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Cells(7,5).Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中

rt.Cells(8,1).Text= "㈱ジェイテクト 亀山工場 御中"
rt.Cells(8,1).Style.FontSize = 10
rt.Cells(8,1).Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Cells(8,1).Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中

rt.Cells(8,5).Text="光洋シーリングテクノ㈱"
rt.Cells(8,5).Style.FontSize = 8
rt.Cells(8,5).Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Cells(8,5).Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中

rt.Style.FontSize = 10  '大体大小为16磅
doc.Body.Children.Add(rt) '将表格对象加入到报表中

doc.PageSetting.Landscape = True '横向打印
doc.Preview() '预览

 回到顶部
帅哥哟,离线,有人找我吗?
狐狸爸爸
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:管理员 帖子:47448 积分:251060 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2020/5/3 8:09:00 [只看该作者]

1、如果要勾选行来生成,可以看看:

2、当然,你也可以增加一个逻辑型的辅助列,用于勾选行:

用基本功能演示文件为例,你加了逻辑列之后,可以这样打印,关键的代码我加粗了:

Dim doc As New PrintDoc '定义一个报表
Dim cnt As Integer = 2 '每页打印两个员工
Dim drs As List(of DataRow) = DataTables("员工").Select("选= True")
For idx As Integer = 0 To drs.Count - 1
   Dim CurRow As DataRow = drs(idx)
    Dim rt As New prt.RenderTable() '定义一个表格对象
    If (idx + 1)  Mod  2 = 0 AndAlso idx < drs.Count - 1 Then  '每两个员工自动换页
        rt.BreakAfter = prt.BreakEnum.Page
    End If

    Dim rx As New prt.RenderText '定义一个文本对象
    '加入标题
    rx.text = "员工资料卡"
    rx.Style.FontBold = True '字体加粗
    rx.Style.FontSize = 16 '大体大小为16磅
    rx.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中排列
    rx.Style.Spacing.Bottom = 3 '和下面的对象(表格)距离3毫米
    doc.Body.Children.Add(rx) '加入到报表中
    '指定行数?列数?列宽?行高
    rt.Rows.Count = 7 '设置总行数
    rt.Cols.Count = 5 '设置总列数
    rt.Height = 80 '设置表格的高度为80毫米
    rt.Rows(6).Height = 40 '设置第7行(显示备注的行)的高度为40毫米,剩余高度被平均分排到其他行
    rt.Cols(0).Width = 24 '设置前四列的宽度,剩余的宽度被分配给5列(显示图片的那列)
    rt.Cols(1).Width = 35
    rt.Cols(2).Width = 24
    rt.Cols(3).Width = 40
    '设置合并单元格
    rt.Cells(0,4).SpanRows = 6 '第1行第5个单元格向下合并6行(用于显示照片)
    rt.Cells(4,1).SpanCols = 3 '第5行第2个单元格向右合并3列(用于显示地址)
    rt.Cells(6,0).SpanCols = 5 '第7行第1个单元格向右合并5列(用于显示备注)
    '设置表格样式
    rt.CellStyle.Spacing.All = 1 '单元格内容缩进1毫米
    rt.Style.GridLines.All = New prt.Linedef '设置网格线
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center '内容垂直居中
    rt.Rows(6).Style.TextAlignVert = prt.AlignVertEnum.Top '唯独第7行是备注,内容靠上对齐
    '下面很简单,指定每一个单元格的内容
    rt.Cells(0,0).Text= "姓名"
    rt.Cells(0,1).Text = CurRow("姓名")
    rt.Cells(0,2).Text= "出生日期"
    rt.Cells(0,3).Text = CurRow("出生日期")
    rt.Cells(1,0).Text= "部门"
    rt.Cells(1,1).Text = CurRow("部门")
    rt.Cells(1,2).Text= "雇佣日期"
    rt.Cells(1,3).Text = CurRow("雇佣日期")
    rt.Cells(2,0).Text= "性别"
    rt.Cells(2,1).Text = CurRow("性别")
    rt.Cells(2,2).Text= "职务"
    rt.Cells(2,3).Text = CurRow("职务")
    rt.Cells(3,0).Text= "城市"
    rt.Cells(3,1).Text = CurRow("城市")
    rt.Cells(3,2).Text= "邮政编码"
    rt.Cells(3,3).Text = CurRow("邮政编码")
    rt.Cells(4,0).Text= "地址"
    rt.Cells(4,1).Text = CurRow("地址")
    rt.Cells(5,0).Text= "家庭电话"
    rt.Cells(5,1).Text = CurRow("家庭电话")
    rt.Cells(5,2).Text= "办公电话"
    rt.Cells(5,3).Text = CurRow("办公电话")
    rt.Cells(6,0).Text = CurRow("备注")
    rt.Cells(0,4).Image = GetImage(CurRow("照片"))
    doc.Body.Children.Add(rt) '将表格对象加入到报表中
Next
Doc.Preview() '预览报表



 回到顶部