I have problems with styles.
What I would like to do is to define some styles with ForeGroundColor, Font and Borders to apply to some cells much like this:
Dim style As Aspose.Cells.Style = Nothing
For i As Integer = 0 To 50
Dim index As Integer = pWorkbook.Styles.Add()
style = pWorkbook.Styles(index)
style.Name = "Custom_Style" + (CType((i + 1), Integer)).ToString()
style.ForegroundColor = Color.White
style.Pattern = BackgroundType.Solid
style.HorizontalAlignment = TextAlignmentType.Left
style.VerticalAlignment = TextAlignmentType.Center
style.Font.Name = "Arial"
style.Font.Size = 10
Next
'Table Footer
style = pWorkbook.Styles(enuStyle.TableFooter)
With style
.Font.IsBold = True
.Font.Size = 12
.ForegroundColor = Color.FromArgb(255, 255, 153) 'Light Yellow
.Pattern = BackgroundType.Solid
.Borders(BorderType.TopBorder).LineStyle = CellBorderType.Thin
.Borders(BorderType.LeftBorder).LineStyle = CellBorderType.Thin
.Borders(BorderType.RightBorder).LineStyle = CellBorderType.Thin
.Borders(BorderType.BottomBorder).LineStyle = CellBorderType.Thin
End With
Later, when I fill cells, I want to apply a style to a column and modify the Custom property like this:
With objSheet.Cells(intRow, 2)
.PutValue(Convert.ToDecimal(drFund.Item("ClosingCapitalConverted")))
.Style = objWorkbook.Styles(enuStyle.TableFooter)
.Style.Number = 3 'Decimal #,##0
End With
The cell is formated with a percent sign and has 2 decimals like this:
259754357255.41% |
If I don't set the style first (.Style = objWorkbook.Styles(enuStyle.TableFooter)), it is working correctly.