黄色部分是原先数据表的列名
红色部分是我想换成的 列名
但是这么做好像不行, 各位请指点一下 非常感谢
Dim tb As Table '定义一个数据表
Dim cn As String '定义一个Grid
Dim ColNames As String() '定义一个数据表列数组
Dim Col_lst As new List(of String) '列集合
Dim c As Integer
Dim iw As Integer
Dim ar1 As String
Dim li As Integer
Dim Grid9 As New prt.RenderTable '定义一个报表数据表对象
tb= Tables("weixindanhao.weixin") '定义一个数据表
'cn="name|30|shuliang|10|price|20|xiaoji|30" '显示列
'Dim ColNames As String() = New String(){"产品", "客户","单价", "数量", "金额"}
ColNames=cn.split("|") '显示列转换
iw=0
For c = 0 To ColNames.Length -1
If c Mod 2=0 Then
iw+=ColNames(c+1)
Grid9.Cells(0,c/2).Text = ColNames(c)
Grid9.Cols(c/2).Width = ColNames(c+1)
If tb.DataTable.datacols(ColNames(c)).IsDate Then
If ColNames(c).contains("-") Then
Grid9.Cells(1, c/2).Text ="[Format(Fields!"&ColNames(c)&".Value,""yyyy-MM-dd"")]" '日期列调整
Else
Grid9.Cells(1, c/2).Text ="[Format(Fields!"&ColNames(c)&".Value,""yyyy/MM/dd"")]" '日期列调整
End If
Else
Grid9.Cells(1, c/2).Text ="[Fields!" & ColNames(c) & ".Value]" '设置绑定表达式
End If
End If
Next
Grid9.RowGroups(1,1).DataBinding.DataSource = BindTables("weixindanhao.weixin") '将第二行绑定到订单表
Grid9.Width=iw '自动宽度
Grid9.Style.TextAlignHorz=prt.AlignHorzEnum.Left '文本对齐,水平
Grid9.Style.TextAlignVert=prt.AlignVertEnum.Top '文本对齐,垂直
Grid9.Style.Font=New System.Drawing.Font("Gulim",9,0,3,1,False) '文本字体
Grid9.Style.BackColor=Color.FromKnownColor(164) '背景颜色
Grid9.Style.TextColor=Color.FromKnownColor(35) '字体颜色
Grid9.CellStyle.Spacing.All=0.5 '单元格文本内距
Grid9.Style.Padding.Left = 5
Grid9.RowGroups(0,tb.HeaderRows).Style.TextAlignHorz=prt.AlignHorzEnum.Left '文本对齐,水平
Grid9.RowGroups(0,tb.HeaderRows).Style.TextAlignVert=prt.AlignVertEnum.Top '文本对齐,垂直
Grid9.RowGroups(0,tb.HeaderRows).Style.Font=New System.Drawing.Font("宋体",9.5,0,3,134,False) '文本字体
Grid9.RowGroups(0,tb.HeaderRows).Style.BackColor=Color.FromKnownColor(164) '背景颜色
Grid9.RowGroups(0,tb.HeaderRows).Style.TextColor=Color.FromKnownColor(35) '字体颜色
Grid9.RowGroups(0,tb.HeaderRows).CellStyle.Spacing.All=1 '单元格文本内距
Dim LineLine3 As New prt.LineDef(1,Color.FromKnownColor(35),DashStyle.Solid)
Dim Line3 As New prt.RenderLine(8,10,76,10, LineLine3) '定义一个线段对象
Dim LineLine4 As New prt.LineDef(1,Color.FromKnownColor(35),DashStyle.Solid)
Dim Line4 As New prt.RenderLine(9.75,30,75.75,30, LineLine4) '定义一个线段对象