Dim tbl As Table = Args(0)
Dim hdr As Integer = tbl.HeaderRows '获得表头的层数
Dim cnt As Integer
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim Style As XLS.Style = Book.NewStyle() '定义新样式
Style.BorderTop = XLS.LineStyleEnum.Thin
Style.BorderBottom = XLS.LineStyleEnum.Thin
Style.BorderLeft = XLS.LineStyleEnum.Thin
Style.BorderRight = XLS.LineStyleEnum.Thin
Style.BorderColorTop = Color.Red
Style.BorderColorBottom = Color.Red
Style.BorderColorLeft = Color.Red
Style.BorderColorRight = Color.Red
Dim St2 As XLS.Style = Book.NewStyle() '定义新样式
St2.BorderTop = XLS.LineStyleEnum.Thin
St2.BorderBottom = XLS.LineStyleEnum.Thin
St2.BorderLeft = XLS.LineStyleEnum.Thin
St2.BorderRight = XLS.LineStyleEnum.Thin
St2.BorderColorTop = Color.Red
St2.BorderColorBottom = Color.Red
St2.BorderColorLeft = Color.Red
St2.BorderColorRight = Color.Red
St2.Format = "yyyy-MM-dd"
tbl.CreateSheetHeader(Sheet) '生成表头
Dim c As Integer =0
For Each c1 As Col In tbl.cols
If c1.Visible Then
For r As Integer = 0 To tbl.Rows.Count - 1
sheet(r + hdr,cnt).value = tbl(r,c)
Next
cnt = cnt + 1
End If
c=c+1
Next
c=0
For Each c1 As Col In tbl.cols
If c1.visible=True
Sheet(0, c).style = style
c=c+1
End If
Next
For r As Integer = hdr-1 To tbl.Rows.Count+hdr - 1 '填入数据
c =0
For Each c1 As Col In tbl.cols
If c1.visible=True
Sheet(r, c).style = style
If tbl.cols(c).Isdate
If r<>tbl.Rows.count+hdr-1
Sheet(r,c).Style = st2
Else
Sheet(r,c).Value = Nothing
End If
End If
c=c+1
End If
Next
Next
Book.Save("c:\reports\test.xls")
Dim Proc As New Process
Proc.File = "c:\reports\test.xls"
Proc.Start()
“合同”两个字没有居中
此主题相关图片如下:无标题.png

[此贴子已经被作者于2018/11/29 20:18:26编辑过]