实现工作表的自定义纸张大小以进行渲染
Contents
[
Hide
]
可能的使用场景
在MS Excel中没有直接选项可以创建自定义纸张尺寸,但是在将Excel文件渲染为PDF文件格式时,您可以设置工作表的所需自定义纸张大小。此文档解释了如何使用Aspose.Cells API设置工作表的自定义纸张大小。
实现工作表的自定义纸张大小以进行渲染
Aspose.Cells允许您实现所需的工作表纸张大小。您可以使用CustomPaperSize类的PageSetup方法来指定自定义页面大小。以下示例代码说明了如何为工作簿中的第一个工作表指定自定义纸张大小。
屏幕截图
示例代码
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 | |
//Create workbook object | |
Workbook wb = new Workbook(); | |
//Access first worksheet | |
Worksheet ws = wb.Worksheets[0]; | |
//Set custom paper size in unit of inches | |
ws.PageSetup.CustomPaperSize(6, 4); | |
//Access cell B4 | |
Cell b4 = ws.Cells["B4"]; | |
//Add the message in cell B4 | |
b4.PutValue("Pdf Page Dimensions: 6.00 x 4.00 in"); | |
//Save the workbook in pdf format | |
wb.Save(outputDir + "outputCustomPaperSize.pdf"); |