We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Applying style to whole worksheet

Hi,

The following statements allowing me applying the style to only one cell at a time. Is there any worksheet method to apply the style to whole worksheet instead of applying style to individual cells.

Aspose.Cells.Style oStyle = oCell.GetStyle();
oStyle.Font = “Times New Roman”;
oStyle.Font.Size = 16;
oCell.SetStyle(oStyle);

Thanks,

Hi,

Please see the following sample code for your need.

Workbook wb = new Workbook();
Worksheet worksheet = wb.Worksheets[0];
Aspose.Cells.Style oStyle = wb.Styles[wb.Styles.Add()];
oStyle.Font.Name = “Times New Roman”;
oStyle.Font.Size = 16;
Aspose.Cells.StyleFlag oFlag = new StyleFlag();
oFlag.FontName = true;
oFlag.FontSize = true;

worksheet.Cells.ApplyStyle(oStyle, oFlag);

wb.Save(“e:\test\outputBook.xls”);


Thank you.