Foxtable(狐表)用户栏目专家坐堂 → 求助 急用


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

主题:求助 急用

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/7/11 10:29:00 [显示全部帖子]

Dim sum1, sum2, sum3, sum4 As Double
sum1 = Tables("应付").Compute("sum(金额)")
sum2 = Tables("应付.应收").Compute("sum(金额)")
sum3 = Tables("应付.已收款录入").Compute("sum(金额)")
sum4 = Tables("应付.扣款录入").Compute("sum(金额)")
e.Form.Controls("合计结果").Text = format(sum1 + sum2 - sum3 - sum4, "#.00")

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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/7/11 11:12:00 [显示全部帖子]

 把窗口打印

 

Dim doc As PrintDoc = e.Form.GernatePrintDoc()
doc.Preview()


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/7/11 11:29:00 [显示全部帖子]

Dim tnames() As String = {"应付", "应付.应收", "应付.已收款录入", "应付.扣款录入"}

Dim doc As New PrintDoc '定义一个新报表
For Each tname As String In tnames
    Dim rt As New prt.RenderTable '定义一个新表格
    Dim tb As Table = Tables(tname)
    Dim ColNames As New List(Of String)
    For Each cl As Col In tb.Cols '排除隐藏列
        If cl.Visible Then
            ColNames.Add(cl.Name)
        End If
    Next
    rt.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
    rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded '表格宽度超出页宽时,可以水平换页
    rt.Style.Font = tb.Font
    For c As Integer = 0 To ColNames.Count - 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 = 0 To tb.Rows.Count -1 '开始填入该列内容
            rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))
        Next
    Next
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
    rt.CellStyle.Spacing.All = 0.5 '单元格内距设为0.5毫米
    rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头.
    rt.Style.Spacing.Bottom = 10
    doc.Body.Children.Add(rt) '将表格加入到报表
Next
    doc.Preview()


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


加好友 发短信
等级:版主 帖子:85326 积分:427815 威望:0 精华:5 注册:2012/10/18 22:13:00
  发帖心情 Post By:2014/7/11 12:04:00 [显示全部帖子]

代码,参考

 

http://www.foxtable.com/help/topics/1166.htm

 

 

Dim tnames() As String = {"应付", "应付.应收", "应付.已收款录入", "应付.扣款录入"}

Dim doc As New PrintDoc '定义一个新报表
For Each tname As String In tnames
    Dim rt As New prt.RenderTable '定义一个新表格
    Dim tb As Table = Tables(tname)
    Dim ColNames As New List(Of String)
    For Each cl As Col In tb.Cols '排除隐藏列
        If cl.Visible Then
            ColNames.Add(cl.Name)
        End If
    Next
    rt.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
    rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded '表格宽度超出页宽时,可以水平换页
    rt.Style.Font = tb.Font
    For c As Integer = 0 To ColNames.Count - 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
        Dim sum As Double = 0
        For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
            rt.Cells(r + 1, c).Text = tb.Rows(r)(ColNames(c))
            If tb.Cols(ColNames(c)).IsNumeric  Then
                sum += tb.Rows(r)(ColNames(c))
            End If
        Next
        If c = 0 Then
            rt.Cells(tb.Rows.Count, c).Text = "合计"
        Else
            rt.Cells(tb.Rows.Count, c).Text = sum
        End If
    Next
    rt.Style.Gridlines.All = New prt.Linedef(Color.Gray) '灰色网格线
    rt.CellStyle.Spacing.All = 0.5 '单元格内距设为0.5毫米
    rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '利用行组,将第一行设为表头.
    rt.Style.Spacing.Bottom = 10
    doc.Body.Children.Add(rt) '将表格加入到报表
Next
doc.PageSetting.Landscape = True
doc.Preview()


 回到顶部