将所有工作表列放在单个页面上 PDF
Contents
[
Hide
]
有时您想要生成一个 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 等查看应用程序中放大时,它仍然可读。
如果您的电子表格包含公式,最好调用工作簿.CalculateFormula()就在将电子表格呈现为 PDF 格式之前。这样做将确保重新计算公式相关值,并在 PDF 中呈现正确的值。