NPOI Change cell backcolor (セルの背景色変更)
Private Sub ChangeCellBackColor()
Dim oldStyle As HSSFCellStyle = Sht.GetRow(rowNum).GetCell(ClmNum).CellStyle
Dim newStyle = wb.CreateCellStyle
With newStyle
.Alignment = oldStyle.Alignment
.WrapText = oldStyle.WrapText
.VerticalAlignment = oldStyle.VerticalAlignment
.SetFont(_srcBook.GetFontAt(oldStyle.FontIndex))
'New Color
.FillPattern = FillPatternType.SOLID_FOREGROUND
.FillForegroundColor = IndexedColors.YELLOW.Index
End With
'Set New Style
Sht.GetRow(rowNum).GetCell(ClmNum).CellStyle = newStyle
End Sub