Apply font family

Hello,


I have two excel spreadsheets. One containing tables with data. Other saved as themes from Excel.
What I wanted to do is export first excel to pdf with theme applied from the second excel sheet.

I am doing as :
Workbook wb1 = new Workbook(excel1);
Workbook wb2 = new Workbook(excel2);
wb1.copyTheme(wb2);

After this saving as pdf.

What I wanted to do here is : set the font as Arial to a PDF that I generate.(This is the only functionality available in themes in excel). But where to add that code. To wb2 or wb1 after copytheme or to pdf before saving and what will be the code?

Thanks,

Hi there,

Thanks for your inquiry. Your query is related to Aspose.Cells API. I am moving this forum thread to Aspose.Cells forum where you'll be guided appropriately.

Hi,

Thanks for your query with details.

I think you may try to create a Style object based on range of cells (which has data in it), specify your desired font attributes. Now create a StyleFlag object and make the relevant options on. Finally apply the style to the range of cells of first workbook sheet(s). See the following sample code for your reference:
e.g.
Sample code:

…
//Get the first
sheet in the workbook, you may do the same for other sheets in a loop (if required)
Worksheet sheet = wb1.Worksheets[0];
Range range = sheet.Cells.MaxDisplayRange;
Style style = wb1.CreateStyle();
style.Font.Name = "Arial";
//set other attributes of Style.Font if you want.
StyleFlag flag = new StyleFlag();
flag.Font = true;
range.ApplyStyle(style, flag);
.............

Hope, this helps a bit.

Thank you.

Thanks for your response.


What I tried today is :

Paste the code you sent. No error thrown but after exporting nothing changed. No arial being applied.

Thanks,

Hi,


We are sorry that you still could not make it. I am afraid, we need your sample(s) to evaluate your issue properly. Please create a sample console demo application (runnable), zip the project and post us here to reproduce the issue with the template files, we will check it soon.

Thank you.