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

Free Support Forum - aspose.com

Including a Font Directory with CellsHelper- doesn't seem to work

Hi again,

Here are some more tips related to the usage of CellsHelper.FontDirs property. Firstly, the following statements should be at the start of your application, that is; before initializing an object of the Workbook class.

string fontDir = GetFontDirectory();<o:p></o:p>

if (fontDir != null)


if (!CellsHelper.FontDirs.Contains(fontDir))



Workbook srcbook = new Workbook("sample.xlsx");

srcbook.Save("D:/output.pdf", SaveFormat.Pdf);

Secondly, could you please try the scenario by changing the method to specify the font directory? For instance, you may alternatively use the property CellsHelper.FontDir that accepts one string value.

Let me tell about what I’ve tried:

(1) I’ve placed the block that sets CellsHelper.FontDirs.Add to the top of my method, so that the code runs before instantiating the Workbook class. This change didn’t make any difference in the output

(2) I tried using CellsHelp.FontDir = fontDir , and that didn’t make a difference either.

(3) Also, in comparing the web.config files between the test app and the production app, I don’t see anything out of the ordinary or that seems relevant to accessing files.

(4) You should also know that my production app also utilizes Aspose.Words. In the Words side, we’re doing exactly the same font embedding as we do for Cells, and it works fine for Word-to-PDF conversions, so that would indicate to me that the problem isn’t IIS or a security setting that would prevent the file from being read.

What might be really helpful would be to expand the WarningCallback interface so that the info.Description indicates why the font substitution failed (file not found, found but not accessible, wrong font properties, etc.)… perhaps someday it could do that.

Thanks for your continued efforts here.

~~ Michael

Hi Michael,

Thank you for troubleshooting the scenario. We really appreciate your input and hopefully we will be able to pin point the problem cause. Please find the attachment for the debug assembly that should create a log file by the name of log.txt in the folder AsposeCells at C drive. Please integrate this assembly in your main application (or a copy of it) and create the folder as narrated above. Upon execution of your application, you will find the C:/AsposeCells/log.txt. Please share it here for further analysis.

Hi Babar,

I’ve incorporated that new version of Cells into my main project and created the folder, as requested. The log.txt file has been attached.

What’s interesting is that in the execution of my app, the directory I’m adding (with CellsHelper.FontDirs.Add is “D:\websites\CustomFonts\0015000000U52DN”)

I check the Log file to see if that directory is listed, and I don’t see it there.

Anyway, I’ll look forward to your thoughts about what all this may mean.

~~ Michael

Hi Michael,

Thanks for your log file and using Aspose.Cells.

It seems, Aspose.Cells is not looking for the required font in the custom directory but trying to locate it from system directory. We will investigate this issue with the help of this log file and let you know what is causing this issue and how to resolve it.

We have therefore logged your comment in our database. Please spare us some time for analyzing this issue. Once, there is some news for you, we will let you know asap.

Hi again,

The product team has reviewed the log shared by you earlier. It seems that your code opened a new Workbook before it saved the firstly opened Workbook to PDF format. Could you please replace the font loading mechanism with CellsHelper.FontDir = fontdir and share the log file again? We need to check where you set the font directory in the code, it has to be first statement before initializing an instance of Workbook and sorry we are pointing this out again n again because it seems that the setting the font directory is not at the start of your application.

Thank you for your patience with us.

We’ve now discovered the issue: we’re calling Aspose.Cells at two different times: first, to merge data into a workbook, then later, in a different class and method, to convert the workbook to PDF. It’s in this second class that we set a customer-specific TTF font directory.

The issue appears to be that since we invoke Aspose Cells early in the proces, we can’t set the font directory in the second class. We confirmed our thoughts by setting the custom font directory in the web app’s Global.asax file, even before applying the Cells license. With it set there, the custom TTF fonts were correctly applied during conversion to PDF. (Annabel, in my case.)

This could be a problem if we can’t specify a customer-specific directory (as opposed to a static directory that contains many customers’ fonts). By using the CellsHelper static class, do the font settings affect all threads?

I’m pretty sure this has been working for us for many years, it seems like this is a fairly recent change.

Anyway, if you can share any thoughts you may have that would allow us to specify a customer-specific directory of TTF fonts that will work in a multi-threaded (IIS web application), that would be helpful.

Note that we use this same behavior in Aspose Words to allow a customer have to have non-shared directory of TTF fonts that are used in the conversion from Word-to-PDF.

Thanks for your thoughts.

One more quick follow-up:

If I put the following line in Global.asax, it all works:

Seems like if it comes after touching anything to do with Aspose.Cells, it doesn’t work.

Hi Michael,

Thanks for your feedback and using Aspose.Cells.

It is such a pleasure to know that your issue is now sorted out. You got it right. CellsHelper.FontDirs as well as License.SetLicense should be used before using any other Aspose.Cells API because later APIs (classes or methods) depend on them. Putting these two things in Global.aspx file is a correct solution because the code inside it executes only once and per application loading and since it is application level thing so it affects all threads in the application. Let us know if you have any other questions, we will be glad to look into them and help you further.

Rats, that’s a problem. Now I have no way to segregate one customer’s fonts from another. I’ll have to make all customer fonts available to every customers.

I’m quite sure Cells didn’t always behave this way, and that’s disappointing, particularly while Words does allow for a separation of fonts.


Thanks for your posting and using Aspose.Cells.

You got a valid point. We have therefore logged your comment in our database against this issue for product team consideration. We will look into it and let you know if there is any workaround or if it is really necessary to keep different customers fonts in different directories. Or a need to set FontDirs anytime, anywhere in the application or threads. Once, we will have some update for you, we will let you know asap.

Hi Michael,

This is to inform you that we will enhance the font setting mechanism to handle the situation as discussed in this thread with the next release of Aspose.Cells for .NET. As soon as the next release is ready for public use, we will notify you here in reference to the ticket CELLSNET-43823.

That’s great news, Babar. Many thanks!

~~ Michael


Thanks for your using Aspose.Cells.

Please download and try the latest fix: Aspose.Cells for .NET v8.5.2.1.

You should use CellsHelper.FontDir or CellsHelper.FontDirs to set font dir.

You should change your following code

if (fontDir != null)
if (!CellsHelper.FontDirs.Contains(fontDir))

to the following code:

if (fontDir != null)
ArrayList fontDirs = CellsHelper.FontDirs;
if (!fontDirs.Contains(fontDir))
CellsHelper.FontDirs = fontDirs;

The issues you have found earlier (filed as CELLSNET-43823) have been fixed in this update.

This message was posted using Notification2Forum from Downloads module by Aspose Notifier.

I solved it with setFontFolders

use aspose\cells\FontConfigs;

$config = new FontConfigs ();
$ font = APPPATH. ‘… / public / assets / fonts’;
$ config-> setFontFolders ([$ font], true);
$ workbook-> CalculateFormula ();
$ temp = TMPPATH. $ _file_name. ‘.pdf’;
$ workbook-> save ($ temp);


Good to know that you have sorted out your issue.

Also, see the document on configuring fonts for rendering spreadsheets for your complete reference.