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

Free Support Forum - aspose.com

How to Set Font Say ' Times New Roman' for Entire WorkSheet

Hi.

Please suggest how to set font of Entire worksheet.

Sunil

Hi Sunil,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

You can use Style.Font.Name to Specify the Font Name. To apply the font style to the whole worksheet, you may have to apply the font style to all the worksheet columns. Please see the following Sample code which will help you to get your desired results.

Sample Code:-

Workbook workbook = new Workbook();

workbook.Open("f:\\Excels\\Input.xls");

//Add Sheet Style

Aspose.Cells.Style stl2 = workbook.Styles[workbook.Styles.Add()];

//Set Font Name

stl2.Font.Name = "Times New Roman";

//Set the style flag struct.

StyleFlag flag = new StyleFlag();

flag.FontName = true;

for (int i=0; i<256;i++)

{

//Apply the style to Columns.

workbook.Worksheets[0].Cells.Columns[i].ApplyStyle(stl2, flag);

}

//Save the Workbook

workbook.Save("F:\\Excels\\Output.xls");

Thank you & Best Regards,