Dim tbl As Table = Tables("表A") Dim hdr As Integer = tbl.HeaderRows Dim Book As New XLS.Book Dim Sheet As XLS.Sheet = Book.Sheets(0) Dim Proc As New Process tbl.CreateSheetHeader(Sheet,0,0,False) Dim st As XLS.Style = Book.NewStyle() '定义新样式st.Format = "yyyy-MM-dd" For c As Integer = 0 To tbl.Cols.Count - 1 If tbl.Cols(c).IsDate Then For r As Integer = 0 To tbl.Rows.Count - 1 sheet(r + hdr,c).value = tbl(r,c) sheet(r + hdr,c).Style = st Next Else For r As Integer = 0 To tbl.Rows.Count - 1 sheet(r + hdr,c).value = tbl(r,c) Next End If Next Book.Save("c:\reports\test.xls") Proc.File = "c:\reports\test.xls" Proc.Start()
|