I extracted a method to apply a series of borders to a given range for a client but the centering of the text was not working and we just realized that if we move the code that centers the cells after the border code the centering comes back.
Right now the method does this
Code:
Range range = worksheet.Cells.CreateRange(firstRow, firstColumn, totalRows, totalColumns); Aspose.CellsStyle borderStyle = workbook.CreateStyle();<span class="keyword">if</span> (TopBorder || AllBorders) borderStyle.Borders[<span class="type">BorderType</span>.TopBorder].LineStyle = CellBorderType.Thin; <span class="keyword">if</span> (BottomBorder || AllBorders) borderStyle.Borders[<span class="type">BorderType</span>.BottomBorder].LineStyle = CellBorderType.Thin; <span class="keyword">if</span> (LeftBorder || AllBorders) borderStyle.Borders[<span class="type">BorderType</span>.LeftBorder].LineStyle = CellBorderType.Thin; <span class="keyword">if</span> (RightBorder || AllBorders) borderStyle.Borders[<span class="type">BorderType</span>.RightBorder].LineStyle = CellBorderType.Thin; borderStyle.Borders.SetColor(<span class="type">Color</span>.Black); range.SetStyle(borderStyle);<!--[if IE]>
<![endif]–>
And then applies that to a given range - is there a way to get the current format of each cell and simply "add" to it instead of overwriting it when applying a style to a range or would I need to go cell by cell?