Foxtable(狐表)用户栏目专家坐堂 → [求助]生成EXCEL报表时,如何可以根据条件生成多个表头及数据


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

主题:[求助]生成EXCEL报表时,如何可以根据条件生成多个表头及数据

帅哥,在线噢!
有点蓝
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


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

比如,细节自行调整

Dim doc As New PrintDoc '定义一个报表
Dim rt As New prt.RenderTable() '定义一个表格对象
doc.Body.Children.Add(rt) '将表格对象加入到报表中
rt.Style.GridLines.All = New prt.Linedef '设置网格线
rt.Cols.Count = 3 '设置总列数
rt.Cells(0,1).SpanCols = 2 
Dim r As Row = Tables("日报").Rows(0)
rt.Cells(0,0).Text = "上日余额"
rt.Cells(0,1).Text = r("余额")

rt.Cells(1,1).SpanCols = 2 
rt.Cells(1,0).Text = "本日收入"
rt.Cells(1,1).Text = DataTables("日报").Compute("sum(借方)","借方 > 0 and 摘要 not like '%计%'")
rt.Cells(2,0).Text = "明细"

Dim drs As List(of DataRow) = DataTables("日报").Select("借方 > 0 and 摘要 not like '%计%'")
Dim cnt As Integer = drs.Count
For i As Integer = 0 To cnt - 1 
    rt.Cells(i+2,1).Text = drs(i)("摘要")
    rt.Cells(i+2,2).Text = drs(i)("借方")
Next

cnt = cnt+3
rt.Cells(cnt,1).SpanCols = 2 
rt.Cells(cnt,0).Text = "本日支出"
rt.Cells(cnt,1).Text = DataTables("日报").Compute("sum(贷方)","贷方 > 0 and 摘要 not like '%计%'")
cnt = cnt+1
rt.Cells(cnt,0).Text = "明细"

cnt = cnt+1

Doc.Preview() '预览报表

 回到顶部