Dim dt As Table = Tables("表A")
Dim hdr As Integer = dt.HeaderRows
Dim cnt As Integer
Dim Book As New XLS.Book() '定义一个Excel工作簿
Dim Sheet As XLS.Sheet = Book.Sheets(0) '引用工作簿的第一个工作表
Dim Style As XLS.Style = Book.NewStyle() '定义新样式
Dim St1 As xls.style = book.newstyle
dt.CreateSheetHeader(Sheet,1,0)
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
Sheet(0,2).Value = "滨湖热力厂节能空间管理"
Sheet(0,9).Value = "打印日期:" & Format(Date.Today, "yyyy年MM月dd日")
St1.FontBold = True
Sheet(0,2).Style = St1
For r As Integer = 1 To 6
For c As Integer =1 To 9
Sheet(r,c).Style = Style
Next
Next
For c As Integer = 0 To dt.Cols.Count - 1
If dt.Cols(c).Visible Then
If dt.Cols(c).Caption Like "*可提升空间" Then
For r As Integer = 0 To dt.Rows.Count - 1
sheet(r + hdr+1,cnt).value = iif(dt(r,c) = 1, "符合", "不符合")
Next
Else
For r As Integer = 0 To dt.Rows.Count - 1
sheet(r + hdr+1,cnt).value = dt(r,c)
Next
End If
cnt = cnt + 1
End If
Next
Sheet.Cols.RemoveAt(2)
Book.Build()
Dim dlg As New SaveFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "Excel文件|*.xls" '设置筛选器
If dlg.ShowDialog = DialogResult.Ok Then
Book.Save(dlg.FileName)
Dim Proc As New Process
Proc.File = dlg.FileName
Proc.Start()
End If