以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]专业报表插入小计行  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=9152)

--  作者:易服
--  发布时间:2011/3/1 16:11:00
--  [求助]专业报表插入小计行

 


图片点击可在新窗口打开查看此主题相关图片如下:2011-3-11 9-54-05.png
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:2011-3-11 9-55-10.png
图片点击可在新窗口打开查看
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:林改信息.rar

密码:888
[此贴子已经被作者于2011-3-11 10:03:23编辑过]

--  作者:狐狸爸爸
--  发布时间:2011/3/1 16:22:00
--  

专业报表的表格,都是自己用代码一行一行加进去的,所以几乎是无所不能的。你可以逐个分组处理,每次用Select方法筛选出这分组的所有行,然后添加到专业报表的表格中,之后添加一个分组行,Compute方法算出算出小计值。

 

这里还有另一个方法:

http://help.foxtable.com/topics/1267.htm

 

 


--  作者:程兴刚
--  发布时间:2011/3/1 18:43:00
--  

没时间弄,您也不给示例文件,调试费劲,给您一段示例代码,自己找合适的改编吧:

 

 

\'\'\'
Dim doc As New PrintDoc() \'定义一个报表
\'doc.PageSetting.Width = 210 \'纸张宽度为100毫米
\'doc.PageSetting.Height = 120 \'纸张高度为120毫米
\'doc.AutoRotate = False \'禁止自动旋转打印内容
\'doc.PageSetting.Landscape = True \'横向打印
Doc.PageSetting.LeftMargin = 25 \'设置左边距
Doc.PageSetting.RightMargin = 15 \'设置右边距
Doc.PageSetting.TopMargin = 20 \'设置上边距
Doc.PageSetting.BottomMargin = 0 \'设置下边距
Dim rt As New prt.RenderTable() \'定义一个表格对象
rt.Style.GridLines.All = New prt.LineDef \'将网格线类型设为默认类型
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center \'水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center \'垂直居中
rt.Style.Spacing.Top = 4 \'表格和前面对象的垂直间隔为4毫米
rt.Style.Spacing.Bottom = 10 \'表和和后续对象的垂直间隔为10毫米
rt.Style.Spacing.All = 2
rt.y = "20mm"
rt.Style.GridLines.All = New Prt.LineDef(0.5,Color.Black)
rt.Style.GridLines.Horz = new Prt.LineDef(Color.Black)
rt.Style.GridLines.Vert = new Prt.LineDef(Color.Black)
rt.Rows.Count = 1 \'设置行数
rt.Cols.Count = 6 \'设置列数
rt.cols(2).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'水平靠右
rt.cols(3).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'水平靠右
rt.cols(4).Style.TextAlignHorz = prt.AlignHorzEnum.Right \'水平靠右
rt.cols(5).Style.TextAlignHorz = prt.AlignHorzEnum.left \'水平靠右
rt.cells(rt.Rows.Count-1,0).Text ="北京燕化集资建房幸福新村1#楼工程部门收支汇总表"
rt.Rows(rt.Rows.Count-1).Height = 13 & "mm"
rt.Rows(rt.Rows.Count-1).Style.GridLines.All = new Prt.LineDef(0,Color.Black)
rt.rows(rt.Rows.Count-1).Style.Font = New Font("宋体", 18,FontStyle.bold) \'设置文本对象的字体
rt.Cells(rt.Rows.Count-1,0).SpanCols = 7 \'第2行第2个单元格向右合并3列
rt.cells(rt.Rows.Count,0).Text = "第[PageNo]页,共[PageCount]页"
rt.Cells(rt.Rows.Count-1,0).SpanCols = 7 \'第2行第2个单元格向右合并3列
rt.rows(rt.Rows.Count-1).Style.Font = New Font("黑体",12) \'设置文本对象的字体
rt.Rows(rt.Rows.Count-1).Height = 6 & "mm"
rt.rows(rt.Rows.Count-1).Style.TextAlignHorz = prt.AlignHorzEnum.Right  \'右对齐
rt.Rows(rt.Rows.Count-1).Style.GridLines.left = new Prt.LineDef(0,Color.Black)
rt.Rows(rt.Rows.Count-1).Style.GridLines.Right =new Prt.LineDef(0,Color.Black)
rt.cells(rt.Rows.Count,0).Text = "序号"
rt.cells(rt.Rows.Count-1,1).Text = "部门/姓名"
rt.cells(rt.Rows.Count-1,2).Text = "应付金额"
rt.cells(rt.Rows.Count-1,3).Text = "已付金额"
rt.cells(rt.Rows.Count-1,4).Text = "未付金额"
rt.cells(rt.Rows.Count-1,5).Text = "备  注"
rt.Rows(rt.Rows.Count-1).Height = 12 & "mm"
rt.rows(rt.Rows.Count-1).Style.Font = New Font("宋体", 12,FontStyle.bold) \'设置文本对象的字体
rt.Rows(rt.Rows.Count-1).Style.BackColor = Color.LightGray \'第一行背景颜色设为灰色.
rt.RowGroups(0,3).Header = prt.TableHeaderEnum.All \'将前三行作为表头.
rt.Cols(0).Width = 12 & "mm"
rt.Cols(1).Width = 35 & "mm"
rt.Cols(2).Width = 35 & "mm"
rt.Cols(3).Width = 35 & "mm"
rt.Cols(4).Width = 35 & "mm"
rt.Cols(5).Width = 45 & "mm"
rt.cells(rt.Rows.Count,0).text = "总计金额:"
rt.Cells(rt.Rows.Count-1,0).SpanCols = 2 \'第2行第2个单元格向右合并3列
rt.cells(rt.Rows.Count-1,2).text = format(DataTables("成本明细帐").Compute("Sum(金额)", "科目 = \'应付款\'"),"0.00")
rt.cells(rt.Rows.Count-1,3).text = format(DataTables("成本明细帐").Compute("Sum(金额)", "科目 = \'已付款\'"),"0.00")
rt.cells(rt.Rows.Count-1,4).text = format(DataTables("成本明细帐").Compute("Sum(金额)", "科目 = \'应付款\'")- DataTables("成本明细帐").Compute("Sum(金额)", "科目 = \'已付款\'"),"0.00")
rt.rows(rt.Rows.Count-1).Style.TextAlignHorz = prt.AlignHorzEnum.Center  \'水平居中
rt.rows(rt.Rows.Count-1).Style.Font = New Font("宋体", 12,FontStyle.bold) \'设置文本对象的字体
rt.Rows(rt.Rows.Count-1).Height = 12 & "mm"
Dim a,b As Integer

Dim Multi As String = DataTables("成本明细帐").GetComboListString("费用类别")
Dim Values() As String
Values = Multi.split("|")
For Index As Integer = 0 To Values.Length - 1
    a = DataTables("成本明细帐").Compute("Sum(金额)", "科目 = \'应付款\' and 费用类别 = \'" & Values(Index)  & "\'")
    b = DataTables("成本明细帐").Compute("Sum(金额)", "科目 = \'已付款\' and 费用类别 = \'" & Values(Index)  & "\'")
    If a = Nothing
        a = 0
    End If
    If b = Nothing
        b = 0
    End If
    rt.cells(rt.Rows.Count,0).text = "      其中:" & Values(Index) & ":"
    rt.cells(rt.Rows.Count-1,0).Style.TextAlignHorz = prt.AlignHorzEnum.left \'水平居左
    rt.Cells(rt.Rows.Count-1,0).SpanCols = 2 \'第2行第2个单元格向右合并3列
    rt.cells(rt.Rows.Count-1,2).text = format(a,"0.00")
    rt.cells(rt.Rows.Count-1,3).text = format(b,"0.00")
    rt.cells(rt.Rows.Count-1,4).text = format(a-b,"0.00")
    rt.Rows(rt.Rows.Count-1).Height = 8 & "mm"
Next
Multi = DataTables("成本明细帐").GetComboListString("部门或单位")
Values = Multi.split("|")
For Index As Integer = 0 To Values.Length - 1
    a = DataTables("成本明细帐").Compute("Sum(金额)", "科目 = \'应付款\' and 部门或单位 = \'" & Values(Index) & "\'")
    b = DataTables("成本明细帐
").Compute("Sum(金额)", "科目 = \'已付款\' and 部门或单位 = \'" & Values(Index) & "\'")
    If a = Nothing
        a = 0
    End If
    If b = Nothing
        b = 0
    End If
    rt.cells(rt.Rows.Count,0).text = format(Index+1,"000")
    rt.cells(rt.Rows.Count-1,1).text = Values(Index)
    rt.cells(rt.Rows.Count-1,2).text = format(a,"0.00")
    rt.cells(rt.Rows.Count-1,3).text = format(b,"0.00")
    rt.cells(rt.Rows.Count-1,4).text = format(a-b,"0.00")
    rt.Rows(rt.Rows.Count-1).Height = 6 & "mm"
    If e.Form.Controls("CheckBox1").Checked = True
        rt.Rows(rt.Rows.Count-1).Style.FontBold = True \'字体加粗
        Dim drs As List(of DataRow) = DataTables("成本明细帐").Select("[部门或单位] = \'" &  Values(Index) & "\'","日期,科目 DESC")
        For Index1 As Integer = 0 To drs.Count-1
            rt.cells(rt.Rows.Count,0).text = "-" & format(Index1+1,"00")
            rt.cells(rt.Rows.Count-1,1).text = Values(Index)
            If drs(Index1)("科目") = "应付款"
                rt.cells(rt.Rows.Count-1,2).text = format(drs(Index1)("金额") ,"0.00")
            Else
                rt.cells(rt.Rows.Count-1,3).text = format(drs(Index1)("金额") ,"0.00")
            End If
            rt.cells(rt.Rows.Count-1,5).text = drs(Index1)("凭证号") & " " & drs(Index1)("费用类别") & " " &  drs(Index1)("备注")
            rt.cells(rt.Rows.Count-1,5).Style.Font = New Font("宋体",8) \'设置文本对象的字体
            rt.cells(rt.Rows.Count-1,0).Style.TextAlignHorz = prt.AlignHorzEnum.Right  \'右对齐
            rt.Rows(rt.Rows.Count-1).Height = 6 & "mm"
        Next
    End If
Next
rt.cells(rt.Rows.Count,0).text =  "      审  核:         记  帐:          经手人:            年    月    日"
rt.rows(rt.Rows.Count-1).Style.Font = New Font("宋体", 12,FontStyle.bold) \'设置文本对象的字体
rt.Cells(rt.Rows.Count-1,0).SpanCols = 7 \'第2行第2个单元格向右合并3列
rt.Rows(rt.Rows.Count-1).Style.GridLines.All = new Prt.LineDef(0,Color.Black)
rt.Rows(rt.Rows.Count-1).Style.GridLines.top = new Prt.LineDef(0.5,Color.Black)
rt.Rows(rt.Rows.Count-1).Height = 15 & "mm"
rt.RowGroups(rt.Rows.Count-1,1).Footer = prt.TableFooterEnum.All \'利用行组,将最后一行设为表尾.
rt.cells(2,2).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中
rt.cells(2,3).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中
rt.cells(2,4).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中
rt.cells(2,5).Style.TextAlignHorz = prt.AlignHorzEnum.Center \'第一行内容水平居中
doc.Body.Children.Add(rt) \'将表格对象加入到报表中
Doc.Preview() \'预览报表

[此贴子已经被作者于2011-3-1 18:45:03编辑过]

--  作者:易服
--  发布时间:2011/3/11 10:09:00
--  
1楼已经更新并上传示例文件,自己实在搞不定插入小计行。
--  作者:baoxyang
--  发布时间:2011/3/11 13:05:00
--  

我用代码写的,可以小计,合计,总计。列汇总,行汇总,报表表名,报表格式都可根据需要来设置。不需要每次来写代码。

另外显示的字段,字体大小,页面的宽度及高度,表头及表尾格式,边框,画线,线宽度。每页行数等都可设置,也可根据每个登陆用户来设置不同的显示方式。


图片点击可在新窗口打开查看此主题相关图片如下:1.jpg
图片点击可在新窗口打开查看

图片点击可在新窗口打开查看此主题相关图片如下:2.jpg
图片点击可在新窗口打开查看

--  作者:baoxyang
--  发布时间:2011/3/11 13:06:00
--  
设置界面如下
图片点击可在新窗口打开查看此主题相关图片如下:3.jpg
图片点击可在新窗口打开查看

--  作者:baoxyang
--  发布时间:2011/3/11 13:08:00
--  

其中,每列的内容的排列方式,列标题的排序顺序,列标题的名称都可根据实际变动或需要来设置的。


--  作者:易服
--  发布时间:2011/3/11 14:05:00
--  
以下是引用baoxyang在2011-3-11 13:08:00的发言:

其中,每列的内容的排列方式,列标题的排序顺序,列标题的名称都可根据实际变动或需要来设置的。

能发个示例文件(打印设置窗口模板也行)参考吗?或在我的代码中搞定

[此贴子已经被作者于2011-3-11 14:09:26编辑过]

--  作者:baoxyang
--  发布时间:2011/3/11 14:25:00
--  
有时间再试试。
--  作者:狐狸爸爸
--  发布时间:2011/3/11 15:07:00
--  
 下载信息  [文件大小:   下载次数: ]
图片点击可在新窗口打开查看点击浏览该文件:管理项目11.table