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


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

主题:专业报表

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


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

 建议在你的表里面加一列表达式,直接引用客户表的客户ID

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


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

以下是引用1234567在2014-6-8 10:36:00的发言:

能否做个实例吗?

 

呃,最基础的问题,参考

 

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

 

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

 


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


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

Dim doc As New PrintDoc '定义一个新报表
Dim rt As New prt.RenderTable '定义一个新表格
Dim tb As Table = Tables("订单")
rt.Width = "Auto" '表格宽度为自动,也就是等于各列设置宽度之和
rt.SplitHorzBehavior = prt.SplitBehaviorEnum.SplitIfNeeded '表格宽度超出页宽时,可以水平换页
rt.Style.Font = tb.Font


rt.Cells(0,0).Text = "客户ID"
For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
    Dim fdr As DataRow = DataTables("客户表").Find("客户 = '" & tb.Rows(r)("客户") & "'")
    If fdr IsNot Nothing Then
        rt.Cells(r + 1, 0).Text = fdr("客户Id")
    Else
        rt.Cells(r + 1, 0).Text = ""
    End If
Next

For c As Integer = 0 To tb.Cols.Count -1 '逐列设置和填入内容
    rt.Cells(0,c+1).Text = tb.Cols(c+1).Name '列名作为标题
    rt.Cells(0,c+1).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
    rt.Cols(c+1).Width = tb.Cols(c+1).PrintWidth '列宽等于实际列宽
    If tb.Cols(c+1).IsNumeric OrElse tb.Cols(c+1).IsDate Then '如果是数值或日期列
        rt.Cols(c+1).Style.TextAlignHorz = prt.AlignHorzEnum.Right '数据水平靠右
    End If
    For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
        rt.Cells(r + 1, c+1).Text = tb(r,c+1)
    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 '利用行组,将第一行设为表头
doc.Body.Children.Add(rt) '将表格加入到报表
doc.Preview()

 


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


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

 哦,应该是如你那样修改,当时改急了。能运行即可。


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


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

 那就这样改一下

 

For r As Integer = 0 To tb.Rows.Count -1 '开始填入该列内容
    rt.Cols(0).Width = 20
    Dim fdr As DataRow = DataTables("客户表").Find("客户 = '" & tb.Rows(r)("客户").split("-")(0) & "'")
    If fdr IsNot Nothing Then
        rt.Cells(r + 1, 0).Text = fdr("客户Id")
    Else
        rt.Cells(r + 1, 0).Text = ""
    End If
Next


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


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

代码

 

Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tbl As Table = Tables("客户")
Dim ColNames As String() = New String(){"客户", "地址", "城市"}
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tbl.DataTable.GetValues("地区")
doc.Pagesetting.LandScape = True
For Each Region As String In Regions
    rx = New prt.RenderText
    rx.Style.FontSize = 14
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 2
    rx.Text = "地区: " & Region
    doc.Body.Children.Add(rx)
    rt = New prt.RenderTable
    rt.Style.Font = Tables("客户").Font
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray)
    rt.Style.Spacing.Bottom = 5
    rt.CellStyle.Spacing.All = 1
    rt.Style.Font = tbl.Font
    Rows = tbl.DataTable.Select("[地区] = '" & Region & "'")
    rt.Cells(0,0).Text = "客户ID"
    Dim filter As String = tbl.Filter
    tbl.Filter = "日期 = #" & Date.Today & "#"

    For r As Integer = 0 To tbl.Rows.Count -1 '开始填入该列内容
        rt.Cols(0).Width = 5
        Dim fdr As DataRow = DataTables("客户表").Find("客户 = '" & Tbl.Rows(r)("客户").split("-")(0) & "'")
        If fdr IsNot Nothing Then
            rt.Cells(r + 1, 0).Text = fdr("客户Id")
        Else
            rt.Cells(r + 1, 0).Text = ""
        End If
    Next
    For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
        rt.Cells(0,c+1).Text = ColNames(c) '列名作为标题
        rt.Cells(0,c+1).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
        rt.Cols(c+1).Width = tbl.Cols(ColNames(c)).PrintWidth '列宽等于实际列宽
        If tbl.Cols(ColNames(c)).IsNumeric OrElse tbl.Cols(ColNames(c)).IsDate Then '如果是数值或日期列
            rt.Cols(c+1).Style.TextAlignHorz = prt.AlignHorzEnum.Right '数据水平靠右
        End If
        For r As Integer = 0 To tbl.Rows.Count -1 '开始填入该列内容
            rt.Cells(r + 1, c+1).Text = tbl.Rows(r)(ColNames(c))
        Next
    Next
    tbl.Filter = filter
    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
    doc.Body.Children.Add(rt)
Next
doc.preview()


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


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

 不可能不符,再改一下,请认真测试。

 

Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tbl As Table = Tables("客户")
Dim ColNames As String() = New String(){"客户", "地址", "城市"}
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tbl.DataTable.GetValues("地区", tbl.Filter)
doc.Pagesetting.LandScape = True
For Each Region As String In Regions
    rx = New prt.RenderText
    rx.Style.FontSize = 14
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 2
    rx.Text = "地区: " & Region
    doc.Body.Children.Add(rx)
    rt = New prt.RenderTable
    rt.Style.Font = Tables("客户").Font
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray)
    rt.Style.Spacing.Bottom = 5
    rt.CellStyle.Spacing.All = 1
    rt.Style.Font = tbl.Font
    Rows = tbl.DataTable.Select("[地区] = '" & Region & "'")
    rt.Cells(0,0).Text = "客户ID"
    Dim filter As String = tbl.Filter
    tbl.Filter = "日期 = #" & Date.Today & "#"
    For r As Integer = 0 To tbl.Rows.Count -1 '开始填入该列内容
        rt.Cols(0).Width = 5
        Dim fdr As DataRow = DataTables("客户表").Find("客户 = '" & Tbl.Rows(r)("客户").split("-")(0) & "'")
        If fdr IsNot Nothing Then
            rt.Cells(r + 1, 0).Text = fdr("客户Id")
        Else
            rt.Cells(r + 1, 0).Text = ""
        End If
    Next
    For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
        rt.Cells(0,c+1).Text = ColNames(c) '列名作为标题
        rt.Cells(0,c+1).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
        rt.Cols(c+1).Width = tbl.Cols(ColNames(c)).PrintWidth '列宽等于实际列宽
        If tbl.Cols(ColNames(c)).IsNumeric OrElse tbl.Cols(ColNames(c)).IsDate Then '如果是数值或日期列
            rt.Cols(c+1).Style.TextAlignHorz = prt.AlignHorzEnum.Right '数据水平靠右
        End If
        For r As Integer = 0 To tbl.Rows.Count -1 '开始填入该列内容
            rt.Cells(r + 1, c+1).Text = tbl.Rows(r)(ColNames(c))
        Next
    Next
    tbl.Filter = filter
    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
    doc.Body.Children.Add(rt)
Next
doc.preview()

 


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


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

 用15楼的代码,感觉不应该。实在不行,就做个简单的例子发上来测试。

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


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

 呵呵,代码写错了,要改成这样

 

Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tbl As Table = Tables("客户")
Dim filter As String = tbl.Filter
tbl.Filter = "日期 = #" & Date.Today & "#"
Dim ColNames As String() = New String(){"客户", "地址", "城市"}
Dim Rows As List(Of DataRow)
Dim Regions As List(Of String) = tbl.DataTable.GetValues("地区", tbl.Filter)
doc.Pagesetting.LandScape = True
For Each Region As String In Regions
    rx = New prt.RenderText
    rx.Style.FontSize = 14
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 2
    rx.Text = "地区: " & Region
    doc.Body.Children.Add(rx)
    rt = New prt.RenderTable
    rt.Style.Font = Tables("客户").Font
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray)
    rt.Style.Spacing.Bottom = 5
    rt.CellStyle.Spacing.All = 1
    rt.Style.Font = tbl.Font
    Rows = tbl.DataTable.Select("[地区] = '" & Region & "'")
    rt.Cells(0,0).Text = "客户ID"
   
    For r As Integer = 0 To tbl.Rows.Count -1 '开始填入该列内容
        rt.Cols(0).Width = 5
        Dim fdr As DataRow = DataTables("客户表").Find("客户 = '" & Tbl.Rows(r)("客户").split("-")(0) & "'")
        If fdr IsNot Nothing Then
            rt.Cells(r + 1, 0).Text = fdr("客户Id")
        Else
            rt.Cells(r + 1, 0).Text = ""
        End If
    Next
    For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
        rt.Cells(0,c+1).Text = ColNames(c) '列名作为标题
        rt.Cells(0,c+1).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
        rt.Cols(c+1).Width = tbl.Cols(ColNames(c)).PrintWidth '列宽等于实际列宽
        If tbl.Cols(ColNames(c)).IsNumeric OrElse tbl.Cols(ColNames(c)).IsDate Then '如果是数值或日期列
            rt.Cols(c+1).Style.TextAlignHorz = prt.AlignHorzEnum.Right '数据水平靠右
        End If
        For r As Integer = 0 To tbl.Rows.Count -1 '开始填入该列内容
            rt.Cells(r + 1, c+1).Text = tbl.Rows(r)(ColNames(c))
        Next
    Next
    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
    doc.Body.Children.Add(rt)
Next
tbl.Filter = filter
doc.preview()


 


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


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

 这次行了!

 

Dim doc As New PrintDoc
Dim rt As Prt.RenderTable
Dim rx As prt.RenderText
Dim tbl As Table = Tables("客户")
Dim ColNames As String() = New String(){"客户", "地址", "城市"}
Dim Rows As List(Of DataRow)
Dim filter As String = "日期 = #" & Date.Today & "#"
Dim Regions As List(Of String) = tbl.DataTable.GetValues("地区", filter)
doc.Pagesetting.LandScape = True
For Each Region As String In Regions
    rx = New prt.RenderText
    rx.Style.FontSize = 14
    rx.Style.FontBold = True
    rx.Style.Spacing.Bottom = 2
    rx.Text = "地区: " & Region
    doc.Body.Children.Add(rx)
    rt = New prt.RenderTable
    rt.Style.Font = Tables("客户").Font
    rt.Style.TextAlignVert = prt.AlignVertEnum.Center
    rt.Style.GridLines.All = New prt.LineDef(0.3,Color.LightGray)
    rt.Style.Spacing.Bottom = 5
    rt.CellStyle.Spacing.All = 1
    rt.Style.Font = tbl.Font
    Rows = tbl.DataTable.Select("[地区] = '" & Region & "' and " & filter)
    rt.Cells(0,0).Text = "客户ID"
   
    For r As Integer = 0 To Rows.Count -1 '开始填入该列内容
        rt.Cols(0).Width = 5
        Dim fdr As DataRow = DataTables("客户表").Find("客户 = '" & Rows(r)("客户").split("-")(0) & "'")
        If fdr IsNot Nothing Then
            rt.Cells(r + 1, 0).Text = fdr("客户Id")
        Else
            rt.Cells(r + 1, 0).Text = ""
        End If
    Next
    For c As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容
        rt.Cells(0,c+1).Text = ColNames(c) '列名作为标题
        rt.Cells(0,c+1).Style.TextAlignHorz = prt.AlignHorzEnum.Center '标题内容水平居中
        rt.Cols(c+1).Width = tbl.Cols(ColNames(c)).PrintWidth '列宽等于实际列宽
        If tbl.Cols(ColNames(c)).IsNumeric OrElse tbl.Cols(ColNames(c)).IsDate Then '如果是数值或日期列
            rt.Cols(c+1).Style.TextAlignHorz = prt.AlignHorzEnum.Right '数据水平靠右
        End If
        For r As Integer = 0 To Rows.Count -1 '开始填入该列内容
            rt.Cells(r + 1, c+1).Text = Rows(r)(ColNames(c))
        Next
    Next
    rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All
    doc.Body.Children.Add(rt)
Next
doc.preview()


 回到顶部
总数 17 1 2 下一页