当前代码如下:
Dim tbl As Table = Tables("党史统计表")
Dim dt1 As Table = Tables("词典")
Dim hdr As Integer = tbl.HeaderRows '获得表头的层数
Dim cnt As Integer
Dim Book As New XLS.Book
Dim Sheet As XLS.Sheet = Book.Sheets(0)
tbl.CreateSheetHeader(Sheet) '生成表头
Sheet.Rows.Insert(0)
Sheet.Rows.Insert(0)
Sheet(0, 0).Value ="党史学习教育开展情况统计表"
Sheet.MergeCell(0,0,1,32)
Sheet(1, 0).Value ="单位"
Sheet.MergeCell(1,2,1,3)
Dim Style As Xls.Style = Book.NewStyle '新建一个线框样式
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
Style.AlignHorz=XLS.AlignHorzEnum.Center
Style.AlignVert=XLS.AlignVertEnum.Center
Style.FontBold = True '字体加粗
Style.Font = New Font("仿宋", 12 , FontStyle.Bold)
Style.WordWrap=True
Dim St21 As Xls.Style = Book.NewStyle '新建一个时间格式化样式
st21.Font = New Font("仿宋", 20 , FontStyle.Bold)
St21.AlignHorz=XLS.AlignHorzEnum.Center
St21.AlignVert=XLS.AlignVertEnum.Center
Dim St2 As Xls.Style = Book.NewStyle '新建一个时间格式化样式
St2.Format = "yyyy-MM-dd"
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.AlignHorz=XLS.AlignHorzEnum.Center
St2.AlignVert=XLS.AlignVertEnum.Center
St2.FontBold = True '字体加粗
St2.Font = New Font("仿宋", 12, FontStyle.Bold)
st2.WordWrap=True
Sheet
For c As Integer = 0 To tbl.Cols.Count - 1
Sheet.Cols(c).Width =80
Next
Sheet.Cols(13).Width =400
Sheet.Cols(16).Width =200
Sheet.Cols(17).Width =400
Sheet.Cols(19).Width =200
Sheet.Cols(20).Width =400
Sheet.Cols(22).Width =400
Sheet.Cols(26).Width =400
Sheet.Cols(30).Width =200
Sheet.Rows(0).Height = 40
Sheet.Rows(1).Height = 40
Sheet.Rows(2).Height = 40
Sheet.Rows(3).Height = 40
For r1 As Integer = 0 To dt1.Rows.Count - 1 '填入数据
For c1 As Integer = 0 To tbl.Cols.Count-1
Sheet(r1+2, 13).Value = dt1.rows(r1)(0)
Sheet(r1+2, 12).Value = r1+1
Next
Next
……