Output Blank Page when there is Nothing to Print

Possible Usage Scenarios

If the sheet is empty, then Aspose.Cells for Python via .NET will not print anything when you export worksheet to image. You can change this behavior by using ImageOrPrintOptions.output_blank_page_when_nothing_to_print property. When you will set it true, it will print the blank page.

Output Blank Page when there is Nothing to Print

The following sample code creates the empty workbook which has an empty worksheet and renders the empty worksheet to an image after setting the ImageOrPrintOptions.output_blank_page_when_nothing_to_print property as true. Consequently, it generates the blank page as there is nothing to print which you can see in the image below.

todo:image_alt_text

Sample Code

from aspose.cells import Workbook
from aspose.cells.drawing import ImageType
from aspose.cells.rendering import ImageOrPrintOptions, SheetRender
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Output directory
outputDir = RunExamples.Get_OutputDirectory()
# Create workbook
wb = Workbook()
# Access first worksheet - it is empty sheet
ws = wb.worksheets[0]
# Specify image or print options
# Since the sheet is blank, we will set OutputBlankPageWhenNothingToPrint to true
# So that empty page gets printed
opts = ImageOrPrintOptions()
opts.image_type = ImageType.PNG
opts.output_blank_page_when_nothing_to_print = True
# Render empty sheet to png image
sr = SheetRender(ws, opts)
sr.to_image(0, outputDir + "OutputBlankPageWhenNothingToPrint.png")