Excel to image

I want to create an image of my excel file but the text is overlapping each other. It seems like it uses another font or a bigger font or something like that. Can anyone help me? This is my code:

private ImageOrPrintOptions getImageOptions(){
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
return imgOptions;
public List<byte[]> render(File f) throws Exception {
List<byte[]> result = new ArrayList<byte[]>();
//Create a workbook object from the template file
Workbook workbook = new Workbook(f.getAbsolutePath());

//Convert each worksheet into svg format
int sheetCount = workbook.getWorksheets().getCount();
for(int i=0; i<sheetCount; i++) {
Worksheet sheet = workbook.getWorksheets().get(i);
SheetRender sr = new SheetRender(sheet, getImageOptions());

for (int k = 0; k < sr.getPageCount(); k++) {
sr.toImage(page, tmp.getAbsolutePath());
// Return the byte arr
return result;
I just want the same image like the preview in excel

Hi Kristof,

Thank you for contacting Aspose support.

Your presented situation could arise when the environment (where conversion is taking place) lacks the fonts used in the spreadsheet. In order to troubleshoot this scenario further, please check which font is being used to format the text, and check if that particular font is available in your environment. You also have to specify the fonts location using the CellsHelper.setFontDir method at the start of your application to get the desired results. Please check the following articles to get a better understanding on why you need the fonts for proper rendering.

In case the problem persists, please provide us the following information for thorough investigation.

  • Operating system version
  • Operating system architecture
  • JDK type (Orcale/OpenJDK/IBM)
  • JDK version
  • Input spreadsheet
  • Resultant image generated on your end, highlighting the problematic areas.

Thank you for the reply. We have tried the solution you’ve mentioned but this did not solve it. The fonts are available at our system. (and we have tested it with multiple fonts)

I’ve diagnosed the problem further and have come to the conclusion that the “overlapping of text” happens when the text in a cell (in the excel file) is formatted bold. I’ve tried it with different fonts and everytime the text is formatted bold, the rendering of the image is faulty.

I have added the excel document we are using to render (named example_bold_rendering.xlsx). I’ve also uploaded a screenshot of the rendering that takes place (excel_to_image_rendering_bold.png). There you can see the overlapping on text with different fonts.

OS: Debian 7.3 (64bit)
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1~deb7u1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)

Thanks in advance and looking forward to a solution,
Regards Kristof

Hi Kristof,

Thank you for sharing your investigation results and environment details. We will shortly test the case on Linux platform and share our results here. In the meanwhile, please try the latest version of Aspose.Cells for Java on your end to see if it makes any difference.

Hi again,

Thank you for your patience with us.

This is to inform you that we have evaluated your presented scenario on Ubuntu & CentOS (both x64 with OpenJDK 1.7) against the latest version of Aspose.Cells for Java, and we are able to replicate the said problem on both of the mentioned environments. We have also noticed that the issue happens when font directory is set in the code (check attached archive for output images).

This incident has been logged in our bug tracking system under the ticket CELLSJAVA-41305 for further investigation & correction purposes. Please spare us little time to properly investigate the matter, and to provide the fix. In the meanwhile, we will keep you posted with updates in this regard.

We have received an e-mail with an update. We already tried the “CellsHelper.setFontDir” and this is not working. I’ve checked it again and can confirm this.

Extra info has been requested but has also already been shared in this thread:

OS: Description: Debian GNU/Linux 7.3 (wheezy) (64bit)
OpenJDK Runtime Environment (IcedTea6 1.12.6) (6b27-1.12.6-1~deb7u1)
OpenJDK 64-Bit Server VM (build 20.0-b12, mixed mode)
Excel file and resulting image have been shared in this thread.

Kind regards

Hi Kristof,

I believe you have received the notification regarding one of our previous response. Please ignore it as we are already able to replicate the problem, and have logged it for product team’s review. I have also checked the status of the ticket logged earlier as CELLSJAVA-41305. Unfortunately, the aforesaid ticket is currently pending for analysis and is in the queue with other investigations. As soon as we receive any updates in this regard, we will post here for your kind reference.

Hello again,

Do you have a workaround to use in the meantime?


Hi Kristof,

We have discussed this matter with the product team, and we regret to inform you that there is no good workaround for this situation until we provide the fix. Please note, the product team has scheduled the ticket CELLSJAVA-41305 for analysis in the current week, and we hope to have some updates in the upcoming week.

That being said, when we last tested the case in Linux environment against the OpenJDK, we noticed that rendering the spreadsheet to image without setting the font directory produces acceptable results (attached). You may test this on your end as well, however, this approach may produce undesired results against the spreadsheets using fonts other than Calibri & Times New Roman so be aware of such scenarios if you choose to use it as a workaround.

Hi again,

This is to inform you that the ticket logged earlier as CELLSJAVA-41305 has been resolved. We will shortly provide the fix here after performing QA and incorporating other enhancements.


Thanks for using Aspose.Cells.

Please try our latest version/fix: Aspose.Cells for Java v8.4.2.1.

We advise that adding the fonts used in excel file by CellsHelper.setFontDir to get a consistent view as in excel print view.

By the way, Calibri font name should be “Calibri”, not “Calabri” you set in excel source file.

Thank you for the fix!

The application is now working like a charm.


Thank you for the confirmation. Please feel free to contact us back in case you need our further assistance with Aspose APIs.

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

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