Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Wed Jun 19, 2019 11:58 am

Hello,

I create a chart type Spire.Xls.ExcelChartType.ColumnClustered, but I need to apply the corporative font (ufonts.com_gotham-book.ttf, saved in a file) to the datalabels of the series and, if possible, to the primary category axis labels and primary value axis labels.

Thanks,

Luis.

lgomez
 
Posts: 6
Joined: Tue Oct 23, 2018 6:39 am

Thu Jun 20, 2019 7:36 am

Hi,

Thanks for your inquiry.
Sorry our Spire.XLS doesn't support applying a custom font for datalabels and category labels at present. We will consider adding this feature into our upgrade list. If the feature is finished, we will inform you.

Sincerely,
Nancy
E-iceblue support team
User avatar

nancy.yang
 
Posts: 184
Joined: Wed Apr 03, 2019 2:33 am

Fri Jun 21, 2019 8:10 am

Ok, thanks.

Luis.

lgomez
 
Posts: 6
Joined: Tue Oct 23, 2018 6:39 am

Thu Jul 11, 2019 11:46 am

Hello,

Thanks for your patient waiting.
Glad to inform you that the feature has been done. Welcome to download the Spire.XLS Pack Version:9.7 and refer to the following code. In generated Excel, you will see that the font name has been changed but the font is not embedded. Actually, the external font is not supported to be embedded in Excel file, this is caused by the interior construction principle of Excel itself. BTW, embedding external font is supported when converting to PDF file. If there is any confusion, just feel free to write back.
Code: Select all
Workbook wb = new Workbook();
wb.LoadFromFile("Book1.xlsx");
Worksheet sheet = wb.Worksheets[0];
Chart chart = sheet.Charts[0];
wb.CustomFontFilePaths = new string[] { "C:\\gotham-book.ttf" };
System.Collections.Hashtable result=wb.GetCustomFontParsedResult();
chart.PrimaryValueAxis.Font.FontName= result["C:\\gotham-book.ttf"] as string;
chart.SecondaryCategoryAxis.Font.FontName = result["C:\\gotham-book.ttf"] as string;
Spire.Xls.Charts.ChartSerie cs1 = chart.Series[0];
cs1.DataPoints.DefaultDataPoint.DataLabels.FontName = result["C:\\gotham-book.ttf"] as string;
wb.SaveToFile("result.xlsx", ExcelVersion.Version2013);
wb.SaveToFile("result.pdf", FileFormat.PDF);
Sincerely,
Nina
E-iceblue support team
Attachments
MyFiles.zip
(83 KiB) Downloaded 158 times
User avatar

Nina.Tang
 
Posts: 1182
Joined: Tue Sep 27, 2016 1:06 am

Return to Spire.XLS