Dim ColNames() As String = {"DDMX_SPHH","DDMX_SPMC","DDMX_SL","DDMX_PFJ", "DDMX_PFJE", "DDMX_LSJ","DDMX_LSJE" } 'ColNames表示列名称,Caption表示列标题
定义一个标题数组
For j As Integer = 0 To ColNames.Length - 1 'Caption 'colNames
rt.Cells(i Mod aPageCount + 1, 0).Text = i + 1
rt.Cells(i Mod aPageCount + 1, j+1).Text = tb.Rows(i)(ColNames(j)) ''colNames
Next
赋值的时候改为标题数组而不是列名
For j As Integer = 0 To ColNames.Length - 1 '逐列设置和填入内容 ''ColNames
rt.Cells(0, j+1).Text = ColNames(j) 'ColNames