import jpype
import asposecells
jpype.startJVM(r"E:\java\jdk-11.0.2\bin\server\jvm.dll")
from asposecells.api import Workbook, FileFormatType, ImageOrPrintOptions, ImageType, ImageFormat, SaveFormat, SheetRender
excel_path = r'E:\code\dock_project\excel_image\excel_files\20220908\ASD_20220908.xlsx'
workbook = Workbook(excel_path)
# create image options
# get sheet count
worksheet = workbook.getWorksheets().get(0)
worksheet.getPageSetup().setPrintArea("B2:AD28")
worksheet.getPageSetup().setLeftMargin(0)
worksheet.getPageSetup().setRightMargin(0)
worksheet.getPageSetup().setTopMargin(0)
worksheet.getPageSetup().setBottomMargin(0)
options = ImageOrPrintOptions()
options.setOnePagePerSheet(True)
options.setImageType(ImageType.TIFF)
options.setQuality(100)
quanlity = options.getQuality()
print('quanlity', quanlity)
options.setVerticalResolution(300)
height = options.getVerticalResolution()
print('height', height)
width = options.setHorizontalResolution(300)
width = options.getHorizontalResolution()
print('width', width)
sr = SheetRender(worksheet, options);
sr.toImage(0, "ERangeofCells_out.tiff")
jpype.shutdownJVM()
参考
https://reference.aspose.com/cells/java/com.aspose.cells/ImageOrPrintOptions