Free Support Forum - aspose.com

Font style for excel sheet

Hi all,

I need a small help. I want to set style as "Century" for the whole excel sheet1. please help me how i can do this.

Any help is appreciated.

Thanks in advane.

Regards,

Bertha.

Hi Bertha,
Thanks for considering Aspoe.
Please refer to the following java code for your need.
//Instantiating a Workbook object
Workbook workbook = new Workbook();
//Accessing the first worksheet in the book.
Worksheet sheet1 = workbook.getWorksheets().getSheet(0);
Cells cells = sheet1.getCells();
//Setting the font name to "Century"
Style style = cells.getCell("A1").getStyle();
style.getFont().setName("Century");
StyleFlag flag = new StyleFlag();
flag.setFontName(true);

for(int i = 0; i< 256; i++)
{
Column column = cells.getColumns().getColumn(i);
column.applyStyle(style,flag);
}

//Saving the Excel file in default (that is Excel 2000) format
workbook.save("E:\\Files\\outputstyles.xls",FileFormatType.DEFAULT);

Thank you.