当没有要打印的内容时输出空白页

可能的使用场景

如果工作表为空,则 Aspose.Cells 在导出工作表为图像时不会打印任何内容。您可以在此使用 ImageOrPrintOptions.OutputBlankPageWhenNothingToPrint 属性进行更改。将其设置为 true,将会打印空白页。

当没有要打印的内容时输出空白页

以下示例代码创建了一个空工作簿,其中包含一个空工作表,并在将 ImageOrPrintOptions.OutputBlankPageWhenNothingToPrint 属性设置为 true 后,将空工作表渲染为图像。因此,生成了一个空白页面,因为没有内容可以打印,您可以在下面的图像中看到。

todo:image_alt_text

示例代码

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET
//Output directory
string outputDir = RunExamples.Get_OutputDirectory();
//Create workbook
Workbook wb = new Workbook();
//Access first worksheet - it is empty sheet
Worksheet 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
ImageOrPrintOptions opts = new ImageOrPrintOptions();
opts.ImageType = Drawing.ImageType.Png;
opts.OutputBlankPageWhenNothingToPrint = true;
//Render empty sheet to png image
SheetRender sr = new SheetRender(ws, opts);
sr.ToImage(0, outputDir + "OutputBlankPageWhenNothingToPrint.png");