When I loop through my recordset and fill in each row, cells that have
no value entered do not have the background color filled in. Below is
part of the related code.
Style:
styleIndex = workbook.Styles.Add()
Dim lw1YellowBGStyle As Style = workbook.Styles(styleIndex)
lw1RedStyle.Font.Name = “Times New Roman”
lw1RedStyle.Font.Size = 10
lw1RedStyle.HorizontalAlignment = TextAlignmentType.Right
lw1RedStyle.Borders(BorderType.TopBorder).LineStyle = CellBorderType.Thin
lw1RedStyle.Borders(BorderType.BottomBorder).LineStyle = CellBorderType.Thin
lw1RedStyle.ForegroundColor = Color.Yellow
lw1RedStyle.Pattern = BackgroundType.Solid
Loop code
cells(worksheetRow, 2).Style = lw1YellowBGStyle
In you sample code, are all "lw1RedStyle" should be "lw1YellowBGStyle"?
I tested with following code and all work fine:
Dim workbook As Workbook = New Workbook()
Dim styleIndex As Integer
styleIndex = Workbook.Styles.Add()
Dim lw1YellowBGStyle As Style = Workbook.Styles(styleIndex)
lw1YellowBGStyle.Font.Name = "Times New Roman"
lw1YellowBGStyle.Font.Size = 10
lw1YellowBGStyle.HorizontalAlignment = TextAlignmentType.Right
lw1YellowBGStyle.Borders(BorderType.TopBorder).LineStyle = CellBorderType.Thin
lw1YellowBGStyle.Borders(BorderType.BottomBorder).LineStyle = CellBorderType.Thin
lw1YellowBGStyle.ForegroundColor = Color.Yellow
lw1YellowBGStyle.Pattern = BackgroundType.Solid
Dim cells As Cells = workbook.Worksheets(0).Cells
Dim worksheetRow As Integer
For worksheetRow = 0 To 10
cells(worksheetRow, 2).Style = lw1YellowBGStyle
Next
workbook.Save("d:\test\abc.xls")
Which version of Aspose.Cells are you using?