Cell borders for all cells

How can I quickly put borders on all the cells in a sheet?


I have tried this, but I’m not getting the results I want:

for (int i = 0; i < WorkBook.Styles.Count; i++)
{
SetBorders(WorkBook.Styles[i]);
}

private void SetBorders(Style style)
{
style.SetBorder(BorderType.LeftBorder, CellBorderType.Medium, Color.Black);
style.SetBorder(BorderType.RightBorder, CellBorderType.Medium, Color.Black);
style.SetBorder(BorderType.TopBorder, CellBorderType.Medium, Color.Black);
style.SetBorder(BorderType.BottomBorder, CellBorderType.Medium, Color.Black);
}

This seems to only affect the styles that I have created.

Basically, I have a “base” style that I want to use for everything with some styles expanding on that. I want to have the font size the same across all, vertical alignment, borders and a few other things.

Hi George,

Thank you for using Aspose products.

I would suggest you to go through the below linked technical articles for your kind reference.

For reusing the style objects, please check the below articles,

In case you still have any questions or face any difficulty, please feel free to write back any time.