Free Support Forum - aspose.com

Cannot find required font definition Exception while loading Excel file in Web app using Aspose.Cells for Java

I need to parse Excel template to get list of Worksheets in web app on the server. I’m getting exception

java.lang.IllegalArgumentException: Cannot find required font defination[Family:Calibri, Style:0]. Please specify font path.
when I’m calling Workbook constructor. How can I overcome this issue, without loading fonts to my web server?
Also, note typo in exception text: defination
Hi,

It seems to be a font related issue. Please set the font directory first via CellsHelper.setFontDir() and then do what you want to perform.

e.g

CellsHelper.setFontDir(pathToYourFontDir);
String filePath = "F:\\File.xlsx";
Workbook workbook = new Workbook(filePath);
workbook.save(filePath + ".out.pdf");

Also, please make sure all the fonts are present (installed) on your computer.

Thank you.

I understand this, but I don’t see the reason to install fonts on web server, when I only need to get list of worksheets

Hi,

Thanks for using Aspose.Cells.

In order to extract the worksheet sheets’ names, Aspose.Cells will have to load the worksheets which require the fonts that are being used in the workbook.

At the moment, Aspose.Cells cannot use any default font which could bypass this exception. So you should install the required fonts on your computer.

I’m not sure why you need to load fonts when you doesn’t need to display anything on the screen. Is it possible that workaroung will be provided in the near future?

Hi,

I think you may try to do one thing as a workaround for your issue now:
Please make sure that at least "Arial" font should be be installed in your environment to retrieve worksheets list only. It may resolve your issue.

Also, we will further look into it and may get back to you soon.

Thank you.



Hi,

Thanks for your input.

We have looked into your issue. If you do not want to install fonts on your machine, then you should set the font path to java default font path.

i.e Java/jre6/lib/fonts etc.

You can do it using CellsHelper.setFontDir() method.

Hello, I’ve fixed issues by copying Arial fonts to the /usr/share/fonts/arial dir

Hi,


Good to know that your issue is resolved by copying Arial fonts to the respective folder(s).

Feel free to contact us any time, if you have any other query or issue, we will be happy to assist you.

Thank you.