Excel を画像に変換

Excel を画像に変換

Aspose.Cells for Python via Java は、Excel ファイルをさまざまな画像形式の画像に変換することをサポートしています。このために、API はシートレンダリングImageOrPrintOptionsクラス。このクラスは、画像にレンダリングされるワークシートを表します。のシートレンダリングクラスが提供するtoImage()ワークシートを画像ファイルに変換するメソッド。 BMP、PNG、JPEG、TIFF、および EMF 形式がサポートされています。

次のコード スニペットは、Excel ワークシートを PNG 画像に変換する方法を示しています。

source_directory = "Examples/SampleFiles/SourceDirectory/"
output_directory = "Examples/SampleFiles/OutputDirectory/"
workbook = Workbook(source_directory + "Book1.xlsx")
imgOptions = ImageOrPrintOptions()
imgOptions.setImageFormat(ImageFormat.getPng())
sheet = workbook.getWorksheets().get(0)
sr = SheetRender(sheet, imgOptions)
for j in range(0, sr.getPageCount()):
sr.toImage(j, output_directory + "WToImage-out%s" %(j) + ".png")