Public Sub
SetCellBackColorCustomColorRGB()
Dim srcWB As HSSFWorkbook = Nothing
Dim filePath = "C:\test.xls"
Using fs As New FileStream(filePath, FileMode.Open, FileAccess.Read)
srcWB = New HSSFWorkbook(fs)
End Using
Dim sheet As HSSFSheet = srcWB.GetSheetAt(0)
Dim cell As HSSFCell = sheet.GetRow(1).GetCell(1)
Dim style As HSSFCellStyle = srcWB.CreateCellStyle
'Get custom palette
Dim palette =
srcWB.GetCustomPalette
'Set color index at palette
palette.SetColorAtIndex(57, 184, 255, 113)
'Set color from color palette
style.FillForegroundColor
= palette.GetColor(57).GetIndex
style.FillPattern = FillPattern.SolidForeground
cell.CellStyle = style
Dim savePath As String = filePath
Using fs As New FileStream(savePath, FileMode.Create, FileAccess.Write)
srcWB.Write(fs)
End Using
MsgBox("done")
End Sub
That solved my problem. thank you.
ReplyDeleteVery good points you wrote here..Great stuff...I think you've made some truly interesting points.Keep up the good work. http://psiprograms.com
ReplyDelete