空白ページを出力する。印刷するものがない場合
Contents
[
Hide
]
可能な使用シナリオ
シートが空白の場合、Aspose.Cellsはワークシートをイメージにエクスポートする際に何も印刷しません。これを変更するには、ImageOrPrintOptions.OutputBlankPageWhenNothingToPrint プロパティを使用します。これを trueに設定すると、空白のページが印刷されます。
印刷するものがない場合、空白ページを出力
次のサンプルコードでは、空のワークシートを含む空のワークブックを作成し、ImageOrPrintOptions.OutputBlankPageWhenNothingToPrint プロパティを trueに設定した後に空のワークシートをイメージにレンダリングします。その結果、何も印刷するものがないため、空白のページが生成されます。画像は以下に表示されています。
サンプルコード
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-.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"); |