累死我了,终于做好了:
Dim flg As New SaveExcelFlags
Tables("A").SaveExcel("E:\表A.Xls","表A",flg)
Dim Book As New XLS.Book("E:\表A.Xls") '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
Sheet.Rows.Insert(0) '在最前面插入一行
Dim Style As XLS.Style = Book.NewStyle() '定义新样式
Style.ForeColor = Color.Red
Dim fnt As New Font("黑体",12,FontStyle.Underline)
Style.Font= fnt
Style.AlignHorz = XLS.AlignHorzEnum.Center
Style.AlignVert = XLS.AlignVertEnum.Center
Dim dt As Table = Tables("A")
For c As Integer = 0 To dt.Cols.Count '添加列标题
Sheet.MergeCell(0,0,1,c)
Sheet(0,0).Value = "导入"
Sheet.Rows(0).Height = 50
Sheet.Cols(0).Width = 100
Sheet(0,0).Style = Style
Next
Book.Save("E:\表A.Xls")
Dim Proc As New Process
Proc.File = "E:\表A.Xls"
Proc.Start()
EXCEL编程,强烈要求加上自动列宽和行高的属性:
这个是VBA的.
Rg.EntireColumn.AutoFit '自动调整列宽
Rg.EntireRow.AutoFit