画像やグラフが含まれる XLS ファイルを PDF ドキュメントに変換する
Contents
[
Hide
]
Aspose.Cells for Python via .NETは、画像やグラフを含むXLSファイルをPDFドキュメントに変換することをサポートしています。Aspose.Cells for Python via .NET APIは、スプレッドシートをPDFに変換するためにAspose.PDF for .NETを必要としません。プロセスは中間XMLファイルに依存せず、メモリ上で行うことができます。これにより、大きなExcelファイル(たとえば、画像やグラフ、その他の描画オブジェクトを含むもの)も迅速かつ効率的に変換できます。
サンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import SaveFormat, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
try: | |
# Get the template excel file path. | |
designerFile = dataDir + "SampleInput.xls" | |
# Specify the pdf file path. | |
pdfFile = dataDir + "Output.out.pdf" | |
# Open the template excel file | |
wb = Workbook(designerFile) | |
# Save the pdf file. | |
wb.save(pdfFile, SaveFormat.PDF) | |
except Exception as e: | |
print(str(e)) | |
input() |
スプレッドシートに数式が含まれている場合、PDFにレンダリングする直前に Workbook.calculate_formula メソッドを呼び出すことが最適です。これにより、数式に依存する値が再計算され、正しい値がPDFにレンダリングされます。