印刷するものがない場合に白紙ページを出力する
Contents
[
Hide
]
考えられる使用シナリオ
シートが空の場合、ワークシートを画像にエクスポートするときに Aspose.Cells は何も印刷しません。を使用して、この動作を変更できます。ImageOrPrintOptions.OutputBlankPageWhenNothingToPrint財産。いつ設定するか真実、空白のページが印刷されます。
印刷するものがない場合に白紙ページを出力する
次のサンプル コードは、空のワークシートを持つ空のワークブックを作成し、空のワークシートを画像にレンダリングします。ImageOrPrintOptions.OutputBlankPageWhenNothingToPrintプロパティとして真実.その結果、以下のように印刷するものが何もないため、空白のページが生成されます。
サンプルコード
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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"); |