实现工作表的自定义纸张大小以进行渲染
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 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 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") |