Setting Font in whole sheet

Hi,


I am able to apply font size, font color etc to my whole sheet except the font name.
My output file is in Excel 2007, its taking default callibri font.
below is the code. please suggest solution.

Aspose.Cells.Style stylefont = wrkBook.Styles[wrkBook.Styles.Add()];
stylefont.Font.Name = “Arial”;
stylefont.Font.Size = 9;
StyleFlag flag = new StyleFlag();
flag.FontName = true;
flag.FontSize = true;
cells.ApplyStyle(stylefont, flag);





Hi Subhankar,

Thank you so much for providing the sample code for the test scenario. Your code is absolutely perfect and working fine. Following are the details of my testing environment.

Operating System: Windows XP
Visual Studio: VS 2005
Aspose Version: V.5.2.2

I think if you are using old version then please try the latest version of Aspose.Cells, find attached for the new version of Aspose.Cells.

If still you face any problem please let us know.

Regards,

Hi,


I used the updated DLL you have attached, but it did not worked for me. Except font name everything is working properly. In my case I am using
VS 2008
.Net 3.5
OS: Win xp pro 32 bit.
Please suggest some workaround.

below is the code I am using:

Cells cells = sheet1.Cells;
Style fontStyle = new Style();
Style style = new Style();
Aspose.Cells.Style stylefont = wrkBook.Styles[wrkBook.Styles.Add()];
stylefont.Font.Name = “Arial”;
stylefont.Font.Size = 9;
StyleFlag flag = new StyleFlag();
flag.FontName = true;
flag.FontSize = true;
cells.ApplyStyle(stylefont, flag);


Regards,
Subhankar.

Hi,

It works absolutely fine using your code. Here is my sample code and attached the output file.

Workbook wrkBook = new Workbook();
Worksheet sheet1 = wrkBook.Worksheets[0];
Cells cells = sheet1.Cells;
Style fontStyle = new Style();
Style style = new Style();
Aspose.Cells.Style stylefont = wrkBook.Styles[wrkBook.Styles.Add()];
stylefont.Font.Name = “Arial”;
stylefont.Font.Size = 9;
StyleFlag flag = new StyleFlag();
flag.FontName = true;
flag.FontSize = true;
cells.ApplyStyle(stylefont, flag);

wrkBook.Save(“e:\test\myoutputfile_testing.xls”);

Thank you.

Hi,


This code is working fine for me also if i save the sheet as Excel 2003 (.xls) format. In my case i have to save it as Excel 2007 (.xlsx) format. Whenever i am saving it to .xlsx format , same is not working.

Hi,

It works fine too if I save the file to XLSX format. I am using the latest version/fix v5.2.0.3(attached), please try it.

Sample code:
Workbook wrkBook = new Workbook();
Worksheet sheet1 = wrkBook.Worksheets[0];
Cells cells = sheet1.Cells;
Style fontStyle = new Style();
Style style = new Style();
Aspose.Cells.Style stylefont = wrkBook.Styles[wrkBook.Styles.Add()];
stylefont.Font.Name = “Arial”;
stylefont.Font.Size = 9;
StyleFlag flag = new StyleFlag();
flag.FontName = true;
flag.FontSize = true;
cells.ApplyStyle(stylefont, flag);

wrkBook.Save(“e:\test\myoutputfile_testing.xlsx”);

the output file is also attached.

Thank you.