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 St2 As XLS.Style = Book.NewStyle
St2.Format = "yyyy-MM-dd"
tbl.CreateSheetHeader(Sheet) '生成表头
For c As Integer = 0 To tbl.Cols.Count - 1
If tbl.Cols(c).Visible Then
For r As Integer = 0 To tbl.Rows.Count - 1
sheet(r + hdr,cnt).value = tbl(r,c)
If tbl.Cols(c).Name = "日期" Then
sheet(r + hdr,cnt).style = st2
End If
Next
cnt = cnt + 1
End If
Next
Book.Save("c:\reports\test.xls")
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("c:\reports\test.xls")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.UsedRange
Rg.BorderAround(MSExcel.XlLineStyle.xlContinuous,MSExcel.XlBorderWeight.xlThick,4)
Rg.Borders.ColorIndex = 1 '边框颜色
App.Visible = True