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


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

主题:[求助]专业报表

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


加好友 发短信
等级:超级版主 帖子:106028 积分:539233 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/8/16 16:45:00 [显示全部帖子]

Dim Doc As New PrintDoc
Dim CurRow As Row = Tables("员工表").Current
Dim tb As Table = Tables("员工表")
Dim ColNames As String() = New String(){"工号", "姓名", "性别","民族","籍贯","身份证号","出生日期","年龄","户籍地","现住址","联系电话","政治面貌","婚姻状况","学历","资格职称"}

'页面设置
Doc.PageSetting.PaperKind = 8
Doc.PageSetting.Landscape = True
Doc.PageSetting.LeftMargin = 14
Doc.PageSetting.RightMargin = 12
Doc.PageSetting.TopMargin = 24
Doc.PageSetting.BottomMargin = 12

Dim cnt As Integer = tb.Rows.Count

Dim prs As Integer = 20 '每页20行
For p As Integer = 0 To math.Ceiling(cnt / prs) - 1
    Dim rt As New prt.RenderTable()
    
    '设置主标题
    rt.Cells(0,0).text = "员工基本信息一览表"
    rt.Cells(0,0).SpanCols = 15
    rt.Cells(0,0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
    rt.Cells(0,0).Style.Font = New Font("宋体", 20, FontStyle.Bold)
    rt.Rows(0).Style.Borders.All = New prt.LineDef("0mm", Color.white)
    rt.Rows(0).Height = 12
    
    rt.Cells(1,0).text = "  单位:" + CurRow("单位名称")
    rt.Cells(1,0).SpanCols = 15
    rt.Cells(1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Left
    rt.Rows(1).Style.Borders.All = New prt.LineDef("0mm", Color.white)
    rt.Rows(1).Style.Borders.Bottom = New prt.Linedef
    rt.Rows(1).Height = 5
    
    '设置列标题
    rt.Cells(2,0).SpanRows = 2 '第1行第1个单元格向下合并2行(显示工号)
    rt.Cells(2,1).SpanCols = 10  '第1行第2列向右合并10个单元格
    rt.Cells(2,11).SpanRows = 2 '第1行第12个单元格向下合并2行(显示政治面貌)
    rt.Cells(2,12).SpanRows = 2 '第1行第13个单元格向下合并2行(显示婚姻状况)
    rt.Cells(2,13).SpanRows = 2 '第1行第14个单元格向下合并2行(显示学历)
    rt.Cells(2,14).SpanRows = 2 '第1行第15个单元格向下合并2行(显示资格职称)
    rt.Cells(2,1).Text = "基本信息"  '第一行第一个单元格的内容
    rt.Cells(2,0).Text= "工号"
    rt.Cells(3,1).Text = "姓名"
    rt.Cells(3,2).Text = "性别"
    rt.Cells(3,3).Text= "民族"
    rt.Cells(3,4).Text = "籍贯"
    rt.Cells(3,5).Text = "身份证号"
    rt.Cells(3,6).Text= "出生日期"
    rt.Cells(3,7).Text = "年龄"
    rt.Cells(3,8).Text = "户籍地"
    rt.Cells(3,9).Text= "现住址"
    rt.Cells(3,10).Text = "联系电话"
    rt.Cells(2,11).Text = "政治面貌"
    rt.Cells(2,12).Text = "婚姻状况"
    rt.Cells(2,13).Text = "学历"
    rt.Cells(2,14).Text = "资格职称"
    
    '设置每页显示表头
    rt.RowGroups(2,2).Style.BackColor = Color.LightGray '第1-2行的颜色设为灰色
    rt.RowGroups(2,2).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第3-4行的文本水平居中
    rt.RowGroups(2,2).Style.TextAlignVert = prt.AlignVertEnum.Center '第3-4行的文本垂直居中
    rt.RowGroups(0,4).Header = prt.TableHeaderEnum.All  '前4行作为表头
    
    '设置列宽/页宽
    rt.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
    rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded '表格宽度超出页宽时,可以水平换页
    
    '设置表格字体
    rt.Style.Font = tb.Font '字体为表格字体
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    
    '填入内容
    For c As Integer = 0 To ColNames.Length - 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 = p * prs To math.min(cnt - 1,( p + 1) * prs - 1) '开始填入该列内容,从第一行到最后一行
            rt.Cells(r + 4, c).Text = tb.Rows(r)(ColNames(c)) '从多层表头以下开始填充第一行(多层表头共4行)
        Next
    Next
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
    rt.CellStyle.Spacing.All = 0.5 '单元格内距设为0.5毫米
    If p < math.Ceiling(cnt / prs) - 1
        rt.BreakAfter = prt.BreakEnum.Page
    End If
    doc.Body.Children.Add(rt)
Next

doc.Preview()


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


加好友 发短信
等级:超级版主 帖子:106028 积分:539233 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/8/19 9:34:00 [显示全部帖子]

 '填入内容


    For c As Integer = 0 To ColNames.Length - 1 
        If tb.Cols(ColNames(c)).IsNumeric Then 
            rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right 
            rt.Style.Font = New Font("Arial Narrow", 7)
        End If
    sum1 = 0
    sum2 = 0
        For r As Integer = p * prs To math.min(cnt - 1,( p + 1) * prs - 1) 
            rt.Cells(r+4, c).Text = tb.Rows(r)(ColNames(c)) 
            sum1 =sum1 + tb.Rows(r)("岗位工资") 
            sum2 =sum2 + tb.Rows(r)("出勤工资")


 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  3楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106028 积分:539233 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/8/19 10:48:00 [显示全部帖子]

  
    '填入内容
    For c As Integer = 0 To ColNames.Length - 1 
        If tb.Cols(ColNames(c)).IsNumeric Then 
            rt.Cols(c).Style.TextAlignHorz = prt.AlignHorzEnum.Right 
            rt.Style.Font = New Font("Arial Narrow", 7)
        End If
        For r As Integer = p * prs To math.min(cnt - 1,( p + 1) * prs - 1) 
            rt.Cells(r+4, c).Text = tb.Rows(r)(ColNames(c)) 
         Next
    Next
For i As Integer = p * prs To math.min(cnt - 1,( p + 1) * prs - 1) 
        rt.Rows(i+tb.HeaderRows).Height = 7 '设置其余的行高
    Next

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  4楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106028 积分:539233 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/8/19 16:13:00 [显示全部帖子]

Dim doc As New PrintDoc
Dim tb As Table = Tables("订单")
Dim prs As Integer = 20
Dim sum1 As Integer = 0
Dim sum2 As Double = 0
Dim tsum1 As Integer = 0
Dim tsum2 As Double = 0
Dim idx1 As Integer= tb.cols("数量").Index
Dim idx2 As Integer= tb.cols("金额").Index
For p As Integer = 0 To math.Ceiling(tb.Rows.Count / prs) - 1
    Dim rt As New prt.RenderTable
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
    rt.CellStyle.Spacing.All = 0.5
    sum1 = 0
    sum2 = 0
    For c As Integer = 0 To tb.Cols.Count - 1
        rt.Cells(0,c).Text = tb.Cols(c).Name
    Next
    For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
        sum1 =sum1 + tb.rows(r)("数量")
        sum2 =sum2 + tb.rows(r)("金额")
        For c As Integer = 0 To tb.Cols.Count - 1
            If tb.Cols(c).IsNumeric
                rt.Cells(r - p * prs + 1, c).Text = format(tb.rows(r)(c),"#,##0.00")
            Else
                rt.Cells(r - p * prs + 1, c).Text = tb.rows(r)(c)
            End If
        Next
    Next
    For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
        rt.Rows(r).Height = 7
    Next
    tsum1 = tsum1 + sum1
    tsum2 = tsum2 + sum2
    rt.Rows.Count = rt.Rows.Count + 1
    rt.Rows(rt.Rows.count -1)(0).text = "本页小计"
    rt.Rows(rt.Rows.count -1)(idx1).text = sum1
    rt.Rows(rt.Rows.count -1)(idx2).text = sum2
    If p = math.Ceiling(tb.Rows.Count / prs) - 1
        rt.Rows.Count = rt.Rows.Count + 1 '增加总计行
        rt.Rows(rt.Rows.count -1)(0).text = "总计"
        rt.Rows(rt.Rows.count -1)(3).text = tsum1
        rt.Rows(rt.Rows.count -1)(6).text = tsum2
    Else
        rt.BreakAfter = prt.BreakEnum.Page '否则换页
    End If
    doc.Body.Children.Add(rt)
Next
doc.Preview()

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  5楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106028 积分:539233 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/8/19 17:34:00 [显示全部帖子]

For c As Integer = 0 To ColNames .length - 1
            If tb.Cols(ColNames (c)).IsNumeric
                rt.Cells(r - p * prs + 1, c).Text = format(tb.rows(r)(ColNames (c)),"#,##0.00")
            Else
                rt.Cells(r - p * prs + 1, c).Text = tb.rows(r)(ColNames (c))
            End If
        Next

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  6楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106028 积分:539233 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/8/19 20:13:00 [显示全部帖子]

For i As Integer = 0 To rt.Rows.Count - 1
    
rt.Cells(i,0).text = i+1 '逐行写入行号
Next

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  7楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106028 积分:539233 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/8/20 9:11:00 [显示全部帖子]

if tb.rows(r)(ColNames (c)) = 0

 回到顶部
帅哥哟,离线,有人找我吗?
有点蓝
  8楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:106028 积分:539233 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2019/8/20 9:59:00 [显示全部帖子]


 回到顶部