Output Blank Page when there is Nothing to Print

Possible Usage Scenarios

If the sheet is empty, then Aspose.Cells will not print anything when you export worksheet to image. You can change this behavior by using ImageOrPrintOptions.OutputBlankPageWhenNothingToPrint property. When you will set it to 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.OutputBlankPageWhenNothingToPrint property as true. Consequently, it generates the blank page as there is nothing to print which you can see as below.

todo:image_alt_text

Sample Code

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String outDir = Utils.Get_OutputDirectory();
// Create workbook
Workbook wb = new Workbook();
// Access first worksheet - it is empty sheet
Worksheet ws = wb.getWorksheets().get(0);
// Specify image or print options
// Since the sheet is blank, we will set
// OutputBlankPageWhenNothingToPrint to true
// So that empty page gets printed
ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.setImageType(ImageType.PNG);
opts.setOutputBlankPageWhenNothingToPrint(true);
// Render empty sheet to png image
SheetRender sr = new SheetRender(ws, opts);
sr.toImage(0, outDir + "OutputBlankPageWhenNothingToPrint.png");