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);
}
}
}