Dim tbl As Table = Tables("表A")
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.font = New Font("Arial",11) ',FontStyle.Bold Or FontStyle.Underline)
style.AlignHorz = XLS.AlignHorzEnum.Center
style.AlignVert = XLS.AlignVertEnum.Center
Style.BorderTop = XLS.LineStyleEnum.Thin
Style.BorderBottom = XLS.LineStyleEnum.Thin
Style.BorderLeft = XLS.LineStyleEnum.Thin
Style.BorderRight = XLS.LineStyleEnum.Thin
Style.BorderColorTop = Color.black
Style.BorderColorBottom = Color.black
Style.BorderColorLeft = Color.black
Style.BorderColorRight = Color.black
Dim St2 As XLS.Style = Book.NewStyle() '定义新样式
st2.font = New Font("Arial",11) ',FontStyle.Bold Or FontStyle.Underline)
St2.BorderTop = XLS.LineStyleEnum.Thin
St2.BorderBottom = XLS.LineStyleEnum.Thin
St2.BorderLeft = XLS.LineStyleEnum.Thin
St2.BorderRight = XLS.LineStyleEnum.Thin
St2.BorderColorTop = Color.black
St2.BorderColorBottom = Color.black
St2.BorderColorLeft = Color.black
St2.BorderColorRight = Color.black
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.Rows(r)(c1.Name)
If c1.IsDate Then
sheet(r + hdr,cnt).style = St2
Else
sheet(r + hdr,cnt).style = Style
End If
Next
cnt = cnt + 1
c=c+1
End If
Next
c=0
For c=0 To Sheet.Cols.Count - 1
Sheet(0, c).style = style
Next
Book.Save("e:\问题\test.xls")
Dim Proc As New Process
Proc.File = "e:\问题\test.xls"
Proc.Start()