Foxtable(狐表)用户栏目专家坐堂 → 请问怎么改呀代码


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

主题:请问怎么改呀代码

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


加好友 发短信
等级:小狐 帖子:311 积分:2288 威望:0 精华:0 注册:2011/9/22 10:21:00
请问怎么改呀代码  发帖心情 Post By:2012/9/5 10:29:00 [只看该作者]

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

 

Dim dt As DataTable
Dim g As New GroupTableBuilder("统计表1", DataTables("fenfa"))
g.Groups.AddDef("faby","投递员")
g.Groups.AddDef("baom","报刊名称")
g.Totals.AddDef("fens","份数")
g.Filter = "[zzrq] >= '1/1/2012 ' And [zzrq] <= '12/31/2012 ' And [pian] = '城西 '"
g.FromServer = True
dt = g.Build(True)
Dim doc As New PrintDoc
Dim rt As New prt.RenderTable
Dim Count As Integer = 0
For Each Col As DataCol In Dt.DataCols
    rt.Cells(0,Count).Text = Col.Name
    For r As Integer = 0 To dt.DataRows.Count - 1
        rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name)
    Next
    Count = Count + 1
Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 1
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Style.Font = New Font("宋体", 20, FontStyle.Bold) '设置字体
rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
rt.Height = 710 '设置表格的高度为120毫米
rt.Cells(1,0).SpanRows = 2
rt.Cells(3,0).SpanRows = 2
rt.Cells(5,0).SpanRows = 2
rt.Cells(7,0).SpanRows = 2
rt.Cells(9,0).SpanRows = 2
rt.Cells(11,0).SpanRows = 2
rt.Cells(13,0).SpanRows = 2
rt.Cells(15,0).SpanRows = 2
rt.Cells(17,0).SpanRows = 2
rt.Cells(19,0).SpanRows = 2
rt.Cells(21,0).SpanRows = 2
rt.Cells(23,0).SpanRows = 2
rt.Cells(25,0).SpanRows = 2
rt.Cells(27,0).SpanRows = 2
rt.Cells(29,0).SpanRows = 2
rt.Cells(31,0).SpanRows = 2
rt.Cells(33,0).SpanRows = 2
rt.Cells(35,0).SpanRows = 2
rt.Cells(37,0).SpanRows = 2
rt.Cells(39,0).SpanRows = 2
rt.Cells(41,0).SpanRows = 2
rt.Cells(43,0).SpanRows = 2
rt.Cells(45,0).SpanRows = 2
rt.Cells(47,0).SpanRows = 2
rt.Cells(49,0).SpanRows = 2
rt.Cells(51,0).SpanRows = 2
rt.Cells(53,0).SpanRows = 2
rt.Cells(55,0).SpanRows = 2
rt.Cells(57,0).SpanRows = 2
rt.Cells(59,0).SpanRows = 2
rt.Cells(61,0).SpanRows = 2
rt.Cells(63,0).SpanRows = 2
rt.Cells(65,0).SpanRows = 2
rt.Cells(67,0).SpanRows = 2
rt.Cells(69,0).SpanRows = 2
rt.Cells(71,0).SpanRows = 2
rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
rt.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Center '第一行内容垂直居中
rt.Rows(0).Style.BackColor = Color.LightGray '第一行背景颜色设为灰色.
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '将第一行作为表头.
doc.Body.Children.Add(rt)
doc.Preview()

原代码如上。

 但是打印出来太多页数了,我想变成如下效果的统计,请问高手,如何写代码呀

 

  投递员    日报   晚报      
   曹晓玲    233    447    

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


加好友 发短信
等级:管理员 帖子:47497 积分:251403 威望:0 精华:91 注册:2008/6/17 17:14:00
  发帖心情 Post By:2012/9/5 11:03:00 [只看该作者]

这种打印,你就用excel报表吧

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


加好友 发短信
等级:狐神 帖子:6708 积分:34304 威望:0 精华:11 注册:2012/8/18 23:10:00
  发帖心情 Post By:2012/9/5 13:58:00 [只看该作者]

在你原来代码上改了些内容,虽方法不太好,勉强用一下吧。最好是把你的项目放上来。

Dim dt As DataTable
Dim g As New GroupTableBuilder("统计表1", DataTables("fenfa"))
g.Groups.AddDef("faby","投递员")
g.Groups.AddDef("baom","报刊名称")
g.Totals.AddDef("fens","份数")
g.Filter = "[zzrq] >= '1/1/2012 ' And [zzrq] <= '12/31/2012 ' And [pian] = '城西 '"
g.FromServer = True
dt = g.Build(True)
Dim doc As New PrintDoc
Dim rt As New prt.RenderTable

Dim Count As Integer = 1
Dim cur_name As String = ""
rt.Cells(0, 0) = "投递员"
rt.Cells(0, 1) = "日报"
rt.Cells(0, 2) = "晚报"
For Each r As DataRow In dt.DataRows
    If r("投递员") <> cur_name Then   '不是同一个投递员
        rt.Cells(count, 0).Text = r("投递员")
        rt.Cells(count, 1).Text = r("份数")   '日报
        cur_name = r("投递员")
    Else
        rt.Cells(count, 2).Text = r("份数")   '晚报
        count = count + 1   '完结
    End If
Next

'Dim Count As Integer = 0
'For Each Col As DataCol In Dt.DataCols
    'rt.Cells(0,Count).Text = Col.Name
    'For r As Integer = 0 To dt.DataRows.Count - 1
        'rt.Cells(r +1,Count).Text = dt.DataRows(r)(Col.Name)
    'Next
    'Count = Count + 1
'Next
rt.Style.Gridlines.All = New prt.Linedef(Color.Gray)
rt.CellStyle.Spacing.All = 1
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center
rt.Style.Font = New Font("宋体", 20, FontStyle.Bold) '设置字体
rt.Style.GridLines.All = New prt.LineDef '将网格线类型设为默认类型
rt.Height = 710 '设置表格的高度为120毫米

'去除了合并的单元格

rt.Style.TextAlignHorz = prt.AlignHorzEnum.Center '水平居中
rt.Style.TextAlignVert = prt.AlignVertEnum.Center '垂直居中
rt.Rows(0).Style.TextAlignHorz = prt.AlignHorzEnum.Center '第一行内容水平居中
rt.Rows(0).Style.TextAlignVert = prt.AlignVertEnum.Center '第一行内容垂直居中
rt.Rows(0).Style.BackColor = Color.LightGray '第一行背景颜色设为灰色.
rt.RowGroups(0,1).Header = prt.TableHeaderEnum.All '将第一行作为表头.
doc.Body.Children.Add(rt)
doc.Preview()
[此贴子已经被作者于2012-9-5 14:02:21编辑过]

 回到顶部