实现工作表的自定义纸张大小以进行渲染
Contents
[
Hide
]
可能的使用场景
MS Excel中没有直接的选项可用于创建自定义纸张大小,但是在将Excel文件呈现为PDF文件格式时,您可以设置所需工作表的自定义纸张大小。本文说明了如何使用Aspose.Cells for Python via .NET API设置工作表的自定义纸张大小。
实现工作表的自定义纸张大小以进行渲染
Aspose.Cells for Python via .NET允许您实现所需工作表的纸张大小。您可以使用custom_paper_size类的PageSetup方法指定自定义页面大小。以下示例代码说明了如何为工作簿中的第一个工作表指定自定义纸张大小。还请参阅以下代码生成的输出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
from aspose.cells import Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create workbook object | |
wb = Workbook() | |
# Access first worksheet | |
ws = wb.worksheets[0] | |
# Set custom paper size in unit of inches | |
ws.page_setup.custom_paper_size(6, 4) | |
# Access cell B4 | |
b4 = ws.cells.get("B4") | |
# Add the message in cell B4 | |
b4.put_value("Pdf Page Dimensions: 6.00 x 4.00 in") | |
# Save the workbook in pdf format | |
wb.save(outputDir + "outputCustomPaperSize.pdf") |