Excelワークシートごとに1つのPDFページをレンダリングする ExcelからPDFへの変換
Contents
[
Hide
]
大量のMicrosoft Excelファイルを使用する場合(たとえば、各シートに50列以上300行以上のデータがあるワークブック)、PDF出力はワークシートごとに1ページで表示したい場合があります。これにより、各ページのページサイズが大幅に異なる可能性があります。これは、Aspose.Cells for Python via .NET APIを使用して達成できます。
複数のワークシートを持つExcelファイルをPDFに変換するサンプルコードをご確認ください。
This file contains hidden or 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 PdfSaveOptions, 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(".") | |
# Initialize a new Workbook | |
# Open an Excel file | |
workbook = Workbook(dataDir + "input.xlsx") | |
# Implement one page per worksheet option | |
pdfSaveOptions = PdfSaveOptions() | |
pdfSaveOptions.one_page_per_sheet = True | |
# Save the PDF file | |
workbook.save(dataDir + "OutputFile.out.pdf", pdfSaveOptions) |
PdfSaveOptions.one_page_per_sheetオプションがtrueに設定されている場合、すべてのシートの内容が1つのPDFページにレンダリングされます。
スプレッドシートに数式が含まれている場合は、PDFに変換する前にWorkbook.calculate_formulaメソッドを呼び出すことが最善です。これにより、数式に依存する値が再計算され、正しい値がPDFにレンダリングされます。