ワークシートのすべての列を単一の PDF ページに合わせる
Contents
[
Hide
]
ワークシートのすべての列を 1 ページに収める PDF ファイルを生成したい場合があります。のPdfSaveOptions.AllColumnsInOnePagePerSheetプロパティは、この機能を非常に使いやすい方法で提供します。出力 PDF の高さと幅などの複雑な計算は内部で処理され、ワークシートのデータに基づいています。
ワークシートの列を単一の PDF ページに合わせる
PdfSaveOptions.AllColumnsInOnePagePerSheetワークシートのすべての列が単一の PDF ページにレンダリングされることを保証しますが、ワークシートのデータによっては行が複数のページに拡張される場合があります。
以下のサンプルコードは、使用方法を示していますPdfSaveOptions.AllColumnsInOnePagePerSheetプロパティを使用して、100 列の大きなワークシートをレンダリングします。
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); | |
// Create and initialize an instance of Workbook | |
Workbook book = new Workbook(dataDir + "TestBook.xlsx"); | |
// Create and initialize an instance of PdfSaveOptions | |
PdfSaveOptions saveOptions = new PdfSaveOptions(); | |
// Set AllColumnsInOnePagePerSheet to true | |
saveOptions.AllColumnsInOnePagePerSheet = true; | |
// Save Workbook to PDF fromart by passing the object of PdfSaveOptions | |
dataDir = dataDir+ "output.out.pdf"; | |
book.Save(dataDir, saveOptions); |
特定のワークシートに多くの列がある場合、レンダリングされた PDF ファイルでは、コンテンツが非常に小さいサイズで表示されることがあります。 Acrobat Reader などの表示アプリケーションで拡大しても、読み取り可能です。
スプレッドシートに数式が含まれている場合は、Workbook.CalculateFormula()スプレッドシートを PDF 形式にレンダリングする直前。そうすることで、式に依存する値が再計算され、正しい値が PDF に表示されるようになります。