Implement Custom Paper Size of Worksheet for Rendering

Possible Usage Scenarios

There is no direct option available to create custom paper sizes in MS Excel, however, you can set custom paper size of your desired worksheets when rendering Excel file to PDF file format. This document explains how to set a custom paper size of a worksheet using Aspose.Cells for Python via .NET APIs.

Implement Custom Paper Size of Worksheet for Rendering

Aspose.Cells for Python via .NET allows you to implement your desired paper size of the worksheet. You may use the custom_paper_size method of the PageSetup class to specify a custom page size. The following sample code illustrates how to specify a custom paper size for the first worksheet in the workbook. Please also see the output PDF generated with the following code for a reference.

Screenshot

todo:image_alt_text

Sample Code

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")