Foxtable(狐表)用户栏目专家坐堂 → [求助]专业报表如何添加分页小计和总计


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

主题:[求助]专业报表如何添加分页小计和总计

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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2011/11/14 14:20:00 [显示全部帖子]


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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2011/11/14 14:25:00 [显示全部帖子]

可以的,你琢磨一下吧

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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2011/11/15 8:30:00 [显示全部帖子]

提示: 定义一个变量Sum,每次换页,Sum = 0,  每打印一行,sum = sum +打印行的值,换页前表格加入一行,打印:本页合计 = sum

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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2011/11/15 9:18:00 [显示全部帖子]

呵呵,是比较难的,打开foxtable的演示文件:统计演示.table,在命令窗口执行:

 

Dim doc As New PrintDoc
Dim tb As Table = Tables("订单")
Dim prs As Integer = 20 '每页20行
Dim sum1 As Integer = 0
Dim sum2 As Double = 0
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
    For c As Integer = 0 To tb.Cols.Count - 1
        rt.Cells(0,c).Text = tb.Cols(c).Name
        For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
            rt.Cells(r - p * prs + 1, c).Text = tb.rows(r)(c)
        Next
    Next
    sum1 = 0
    sum2 = 0
    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)("金额")
    Next
    rt.Rows.Count = rt.Rows.Count + 1
    rt.Rows(rt.Rows.count -1)(0).text = "本页小计"
    rt.Rows(rt.Rows.count -1)(5).text = sum1
    rt.Rows(rt.Rows.count -1)(6).text = sum2
    If p < math.Ceiling(tb.Rows.Count / prs) - 1
        rt.BreakAfter = prt.BreakEnum.Page
    End If
    doc.Body.Children.Add(rt)
Next
doc.Preview()


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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2011/11/16 8:25:00 [显示全部帖子]

打开foxtable的演示文件:统计演示.table,在命令窗口执行:

 

Dim doc As New PrintDoc
Dim tb As Table = Tables("订单")
Dim prs As Integer = 20 '每页20行
Dim sum1 As Integer = 0
Dim sum2 As Double = 0
Dim tsum1 As Integer = 0
Dim tsum2 As Double = 0
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
    For c As Integer = 0 To tb.Cols.Count - 1
        rt.Cells(0,c).Text = tb.Cols(c).Name
        For r As Integer = p * prs To math.min(tb.Rows.Count - 1,( p + 1) * prs - 1)
            rt.Cells(r - p * prs + 1, c).Text = tb.rows(r)(c)
        Next
    Next
    sum1 = 0
    sum2 = 0
    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)("金额")
    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)(3).text = sum1
    rt.Rows(rt.Rows.count -1)(6).text = sum2
    If p < math.Ceiling(tb.Rows.Count / prs) - 1
        rt.BreakAfter = prt.BreakEnum.Page
    Else
        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
    End If
    doc.Body.Children.Add(rt)
Next
doc.Preview()


 回到顶部