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

Free Support Forum - aspose.com

Why is it recognized as zip

https://tezign-assets.oss-cn-beijing.aliyuncs.com/00ceda2ae82892e3ea20fdfa3b9b5cf7.xlsx

public static void main(String[] args) throws Exception {
Workbook book = new Workbook("");
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.setImageType(ImageType.JPEG);
imgOptions.setOutputBlankPageWhenNothingToPrint(false);
imgOptions.setHorizontalResolution(300);
imgOptions.setVerticalResolution(300);
imgOptions.setCheckWorkbookDefaultFont(true);
imgOptions.setAllColumnsInOnePagePerSheet(true);
imgOptions.setQuality(50);
// 指示当单元格字体不兼容时是否只替换字符的字体。
imgOptions.setFontSubstitutionCharGranularity(true);
final String filename = “asdsad.jpg”;
// Get the first worksheet.
final WorksheetCollection worksheets = book.getWorksheets();

    for (int i = 0; i < worksheets.getCount(); i++) {
        // Create a SheetRender object for the target sheet
        final Worksheet sheet = worksheets.get(i);
        sheet.getPageSetup().setPrintGridlines(true);
        sheet.getCells().deleteBlankRows();
        sheet.getCells().deleteBlankColumns();
        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 = "aa.jpg";
            log.info("excel outputFilePath:"+name);
            final Instant now = Instant.now();
            sr.toImage(j, name);
            
        }
    }
}

@zyx,
Could you please share the sample Excel file again? You may zip the Excel file before attaching it here on the forum.

You may describe the issue little more like where do you recognize it as zip. Are you getting the saved image as zip file?

@zyx,

I was able to download your attachment from its source in your first post. When I tried to open into MS Excel, it gives an error and denotes it as not a valid Excel file. When I opened your file into notepad, it gives this display, see what contents are shown of your file in the screenshot (attached).
sc_shot1.png (11.5 KB)

In short, your so called XLSX file is not a valid MS Excel file, it’s kind of error which is retrieved/saved in text file. As asked by Ahsan Iqbal, please re-attach a valid Excel file, so we could evaluate your issue precisely.