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

Free Support Forum - aspose.com

Excel convert images fail

Workbook book = new Workbook("/Users/zyx/Desktop/974246-NPD-HC(1).xlsx.xlsx");
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

    final String filename = "/Users/zyx/Desktop/excelImage/aaa";
    // Get the first worksheet.
    final WorksheetCollection worksheets = book.getWorksheets();
    List<String> list = new ArrayList(worksheets.getCount() * 4);
    for (int i = 0; i < worksheets.getCount(); i++) {
        // Create a SheetRender object for the target sheet
        SheetRender sr = new SheetRender(worksheets.get(i), imgOptions);
        for (int j = 0; j < sr.getPageCount(); j++) {
            // Generate an image for the worksheet
            final String name = filename + "sheet" + (i+1) + "_" + (j+1) + ".jpg";
            sr.toImage(j, name);

974246-NPD-HC(1).xlsx.xlsx.zip (11.2 KB)
excelImage.zip (992.2 KB)

The conversion effect is very poor. Can you tell me why?


We have logged the issue as “CELLSJAVA-43476” in our database for investigations of low quality images. Once we will have some news for you, we will update you in this topic.


Please extend the horizontal and vertical resolutions, it will enhance the quality of the rendered JPG images. See the sample lines (in bold) of code for your reference:
Sample code:

ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

Let us know if you still see any low quality images.

It seems to be better, but there are still no grid lines. What is the reason?


Please note, there are lots of cells with font settings to “Calibri”, however the font “Calibri” can’t render Chinese characters properly. So, please set imgOptions.setDefaultFont("宋体") to prefer to use font “宋体” in this case. Also set horizontal and vertical resolution to further higher value to get better image.
Sample code:

ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();

If you could take the print preview of the sheet, you will also notice there are no gridlines. If you want to render gridlines of the sheet, you may use the PageSetup option. See the sample line of code:

Hope, this helps a bit.

When there is no font, can I specify a series of fonts, when the previous font does not exist, use the following

imgOptions.setDefaultFont(“宋体,思源宋体,PingFang TC,SourceHanSerifSC-Regular,Source Han Serif SC,SourceHanSerifTW-Heavy,Arial”);


You cannot specify series of fonts (list) using imgOptions.setDefaultFont. However, you can try to use the method, i.e., FontConfigs.SetFontSubstitutes(string originalFontName, string[] substituteFontNames)
Please note, you need to specify the parameter ‘orginalFontName’ used in the source file.

sure,I also found this after checking the api, but I still want to thank you


Alright, in the event of further queries or comments, feel free to write us back.