Stampa pagina vuota quando non c'è niente da stampare
Possibili scenari di utilizzo
Se il foglio è vuoto, Aspose.Cells non stamperà nulla quando si esporta il foglio di lavoro nell’immagine. È possibile modificare questo comportamento utilizzandoImageOrPrintOptions.OutputBlankPageWhenNothingToPrint proprietà. Quando lo imposterai suVERO, stamperà la pagina vuota.
Stampa pagina vuota quando non c’è niente da stampare
Il seguente codice di esempio crea la cartella di lavoro vuota che ha un foglio di lavoro vuoto ed esegue il rendering del foglio di lavoro vuoto in un’immagine dopo aver impostato ilImageOrPrintOptions.OutputBlankPageWhenNothingToPrintproprietà comeVERO. Di conseguenza, genera la pagina vuota in quanto non c’è nulla da stampare che puoi vedere come sotto.
Codice d’esempio
// 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"); |