Dim tbl As Table = Tables("表A")
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
Dim St1 As XLS.Style = Book.NewStyle
St1.Format = "yyyy-MM-dd"
Sheet.Cols(tbl.Cols("出生日期").Index).Style = st1
Dim hdr As Integer = tbl.HeaderRows '获得表头的层数
tbl.CreateSheetHeader(Sheet) '生成表头
Dim cnt As Integer
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)
Next
cnt = cnt + 1
End If
Next
Book.Save("D:\reports\表A.xls")
Dim App As New MSExcel.Application
Dim Wb As MSExcel.WorkBook = App.WorkBooks.Open("D:\reports\表A.xls")
Dim Ws As MSExcel.WorkSheet = Wb.WorkSheets(1)
Dim Rg As MSExcel.Range = Ws.UsedRange
Rg.EntireColumn.AutoFit '自动调整列宽
Rg.EntireRow.AutoFit '自动调整行高
Rg.Font.Size = 11
Rg.Borders.Linestyle = MSExcel.XlLineStyle.xlContinuous '边框线型
Rg.Borders.Weight = MSExcel.XlBorderWeight.xlThin'边框粗细
App.Visible = True
Dim Proc As New Process '定义一个新的Process
Proc.File = "D:\Reports" '指定文件夹路径
Proc.Start()