Excelワークシートごとに1つのPDFページをレンダリングする ExcelからPDFへの変換
Contents
[
Hide
]
大きなMicrosoft Excelファイル(たとえば、各50列と300行以上のデータを持つ多くのシートがあるワークブック)を使用して作業する場合、ワークシートごとに1ページでPDF出力されるようにしたい場合があります。これにより、各ページがおそらく大きく異なるページサイズになります。これは、Aspose.Cells for .NETを使用することで達成できます。
複数のワークシートを持つExcelファイルをPDFに変換するサンプルコードをご確認ください。
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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Initialize a new Workbook | |
// Open an Excel file | |
Workbook workbook = new Workbook(dataDir+ "input.xlsx"); | |
// Implement one page per worksheet option | |
PdfSaveOptions pdfSaveOptions = new PdfSaveOptions(); | |
pdfSaveOptions.OnePagePerSheet = true; | |
// Save the PDF file | |
workbook.Save(dataDir+ "OutputFile.out.pdf", pdfSaveOptions); |
OnePagePerSheetオプションがtrueに設定されている場合、すべてのシートコンテンツが1つのPDFページにレンダリングされます。
スプレッドシートに数式が含まれている場合、スプレッドシートをPDFにレンダリングする直前にWorkbook.CalculateFormula()を呼び出すことが最善です。これにより、数式に依存した値が再計算され、正しい値がPDFに表示されます。