-- 作者:周子杰
-- 发布时间:2012/8/29 17:10:00
-- 请问如何写合并相同单元格的代码呀
此主题相关图片如下:2.jpg
请指教:我想变成如下格式:
faby |
pian |
年 |
日报 |
晚报 |
|
曹晓玲 |
城西 |
2012 |
233 |
477 |
|
狄文斌 |
城西 |
2012 |
151 |
377 |
|
原代码如下:
Dim dt As DataTable Dim g As New GroupTableBuilder("统计表1", DataTables("fenfa")) g.Groups.AddDef("faby") g.Groups.AddDef("pian") g.Groups.AddDef("zzrq", DateGroupEnum.Year, "年") 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 doc.Body.Children.Add(rt) doc.Preview()
|
-- 作者:周子杰
-- 发布时间:2012/9/3 18:21:00
--
Dim dt As DataTable Dim g As New GroupTableBuilder("统计表1", DataTables("fenfa")) g.Groups.AddDef("faby") g.Groups.AddDef("pian") g.Groups.AddDef("zzrq", DateGroupEnum.Year, "年") 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 doc.Body.Children.Add(rt) doc.Preview()
上面代码和您给的代码,不会组合了,请给提示
|