如题,下面代码导不出 绘制单元格的颜色, 要导出绘制单元格颜色,求助
Dim tt As Table = Tables("员工资料") Dim file As String = "d:\内部通讯录.xls" Dim flg As New SaveExcelFlags flg.CellStyle = True tt.SaveExcel(file ,tt.name,flg)
Dim Book As New XLS.Book(file) Dim Sheet1 As XLS.Sheet = Book.Sheets(0) Dim Style As XLS.Style = Book.NewStyle() '定义新样式 Style.ForeColor = Color.Crimson '设置样式的字体颜色 'Style.ForeColor = Color.Blue '设置样式的字体颜色 Style.FontBold = True 'Style.BackColor = Color.Cyan 'Style.BackColor = Color.LightCyan Style.BackColor = Color.LightGray
Style.BorderTop = XLS.LineStyleEnum.None Style.BorderBottom = XLS.LineStyleEnum.None Style.BorderLeft = XLS.LineStyleEnum.None Style.BorderRight = XLS.LineStyleEnum.None style.AlignVert = XLS.AlignVertEnum.Center
For n As Integer = 0 To Sheet1.Rows.Count -1
''导出逻辑列 打钩 'If Sheet1(n,6).Value = "1" Then 'Sheet1(n,6).Value = "√" 'Else 'Sheet1(n,6).Value = "" 'End If ''导出逻辑列 打钩
If Sheet1(n,0).Value.contains("_") Then If n > 2 Then For c As Integer = 0 To 39 Sheet1 (n,c).Style = Style Next End If Else For c As Integer = 0 To 39 try 'If Sheet1(n,c).Style.BackColor.G <> 255 Then If Sheet1(n,c).Style.BackColor.G <> 255 OrElse Sheet1(n,c).Style.BackColor.R <> 255 OrElse Sheet1(n,c).Style.BackColor.B <> 255 Then Else Sheet1(n,c).Style = book.NewStyle End If catch ex As exception Sheet1(n,c).Style = book.NewStyle End try Sheet1(n,c).Style.BorderTop = XLS.LineStyleEnum.Thin Sheet1(n,c).Style.BorderBottom = XLS.LineStyleEnum.Thin Sheet1(n,c).Style.BorderLeft = XLS.LineStyleEnum.Thin Sheet1(n,c).Style.BorderRight = XLS.LineStyleEnum.Thin Sheet1(n,c).Style.BorderColorTop = Color.Gray Sheet1(n,c).Style.BorderColorBottom = Color.Gray Sheet1(n,c).Style.BorderColorLeft = Color.Gray Sheet1(n,c).Style.BorderColorRight = Color.Gray Sheet1(n,c).Style.AlignVert = XLS.AlignVertEnum.Center Sheet1(n,c).Style.AlignHorz = XLS.AlignHorzEnum.Center Next End If Next
Book.Save(file) Dim Proc As New Process Proc.File = file Proc.Start()
|