Format ALL cells in a worksheet


#1

Is there a way to format all the cells in a worksheet other than setting a range and using a style? For example if I want all the cells in my worksheet to be Arial size 8.

TIA


#2

To format a whole workbook:

Excel excel = new Excel();
Style style = excel.DefaultStyle;
style.Font.Size = 8;
excel.DefaultStyle = style;

To format a whole worksheet:

Excel excel = new Excel();

Cells cells = excel.Worksheets[0].Cells;
for(int i = 0; i < 256; i ++)
{
Style style = cells.Columns[(byte)i].Style;
style.Font.Size = 8;
cells.Columns[(byte)i].Style = style;

}


#3

Thanks for the quick response. (BTW I'm using Aspose.Cells for .NET)

I tried the below code and got "Style is read only"

Dim i As Integer
For i = 0 To i < 256
cTrend.Columns(CType(i,byte)).Style = SARExcel.Styles("DataStyleGeneric")
Next

When I looked at the Columns members Style was not listed. It was under the Column members??