印刷オプションの設定
印刷オプションの設定
これらの印刷オプションにより、ユーザーは次のことができます。
- ワークシート上の特定の印刷領域を選択します。
- タイトルを印刷します。
- グリッド線を印刷します。
- 行/列の見出しを印刷します。
- ドラフト品質を実現します。
- コメントを印刷します。
- セル エラーを出力します。
- ページの順序を定義します。
Aspose.Cells は、Microsoft Excel が提供するすべての印刷オプションをサポートし、開発者は、ページ設定クラス。これらのプロパティがどのように使用されるかについては、以下で詳しく説明します。
印刷範囲の設定
デフォルトでは、データを含むワークシートのすべての領域が印刷領域に組み込まれます。開発者は、ワークシートの特定の印刷領域を設定できます。
特定の印刷領域を選択するには、ページ設定クラス'印刷エリア財産。印刷領域を定義するセル範囲をこのプロパティに割り当てます。
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Obtaining the reference of the PageSetup of the worksheet | |
PageSetup pageSetup = workbook.Worksheets[0].PageSetup; | |
// Specifying the cells range (from A1 cell to T35 cell) of the print area | |
pageSetup.PrintArea = "A1:T35"; | |
// Save the workbook. | |
workbook.Save(dataDir + "SetPrintArea_out.xls"); |
印刷タイトルの設定
Aspose.Cells を使用すると、印刷されたワークシートのすべてのページで行ヘッダーと列ヘッダーを繰り返すように指定できます。これを行うには、ページ設定クラス'PrintTitleColumnsとPrintTitleRowsプロパティ。
繰り返される行または列は、行番号または列番号を渡すことによって定義されます。たとえば、行は $1:$2 として定義され、列は $A:$B として定義されます。
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Obtaining the reference of the PageSetup of the worksheet | |
Aspose.Cells.PageSetup pageSetup = workbook.Worksheets[0].PageSetup; | |
// Defining column numbers A & B as title columns | |
pageSetup.PrintTitleColumns = "$A:$B"; | |
// Defining row numbers 1 & 2 as title rows | |
pageSetup.PrintTitleRows = "$1:$2"; | |
// Save the workbook. | |
workbook.Save(dataDir + "SetPrintTitle_out.xls"); |
その他の印刷オプションの設定
のページ設定クラスには、次のような一般的な印刷オプションを設定するためのその他のプロパティもいくつか用意されています。
- PrintGridlinesグリッド線を印刷するかどうかを定義するブール型のプロパティ。
- 印刷見出し行と列の見出しを印刷するかどうかを定義するブール型のプロパティ。
- 黒と白ワークシートを白黒モードで印刷するかどうかを定義するブール値のプロパティ。
- 印刷コメント: 印刷コメントをワークシートに表示するか、ワークシートの最後に表示するかを定義します。
- 下書きを印刷グラフィックなしでシートを印刷するかどうかを定義するブール値のプロパティ..
- 印刷エラー: セル エラーを表示、空白、ダッシュ、または N/A として出力するかどうかを定義します。
を設定するには印刷コメントと印刷エラープロパティ、Aspose.Cells は 2 つの列挙も提供します。PrintCommentsType 、 とPrintErrorsTypeに割り当てられる定義済みの値が含まれています。印刷コメントと印刷エラープロパティ。
の定義済みの値PrintCommentsType列挙は、その説明とともに以下にリストされています。
印刷コメントの種類 | 説明 |
---|---|
PrintInPlace | ワークシートに表示されているコメントを印刷するように指定します。 |
PrintNoComments | コメントを印刷しないように指定します。 |
PrintSheetEnd | ワークシートの最後にコメントを印刷するように指定します。 |
の定義済みの値PrintErrorsType列挙は、その説明とともに以下にリストされています。
印刷エラーの種類 | 説明 |
---|---|
PrintErrorsBlank | エラーを出力しないように指定します。 |
PrintErrorsDash | エラーを「–」として出力するように指定します。 |
PrintErrorsDisplayed | エラーを表示どおりに印刷するように指定します。 |
印刷エラーNA | エラーを「#N/A」として出力するように指定します。 |
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Obtaining the reference of the PageSetup of the worksheet | |
PageSetup pageSetup = workbook.Worksheets[0].PageSetup; | |
// Allowing to print gridlines | |
pageSetup.PrintGridlines = true; | |
// Allowing to print row/column headings | |
pageSetup.PrintHeadings = true; | |
// Allowing to print worksheet in black & white mode | |
pageSetup.BlackAndWhite = true; | |
// Allowing to print comments as displayed on worksheet | |
pageSetup.PrintComments = PrintCommentsType.PrintInPlace; | |
// Allowing to print worksheet with draft quality | |
pageSetup.PrintDraft = true; | |
// Allowing to print cell errors as N/A | |
pageSetup.PrintErrors = PrintErrorsType.PrintErrorsNA; | |
// Save the workbook. | |
workbook.Save(dataDir + "OtherPrintOptions_out.xls"); |
ページの順序を設定する
のページ設定クラスが提供する注文ワークシートの複数ページの印刷を注文するために使用されるプロパティ。ページの順序には、次の 2 つの方法があります。
- **下から上へ:**右側のページを印刷する前に、すべてのページを下に印刷します。
- **オーバー・アンド・ダウン:**下のページを印刷する前に、ページを左から右に印刷します。
Aspose.Cells は列挙を提供し、PrintOrderType定義済みの注文タイプがすべて含まれています。
の定義済みの値PrintOrderType以下に列挙します。
印刷注文の種類 | 説明 |
---|---|
ダウン・ザ・オーバー | 印刷順序を下から上に表します。 |
オーバー・ザ・ダウン | 印刷順序を上から下に表します。 |
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-.NET | |
// The path to the documents directory. | |
string dataDir = RunExamples.GetDataDir(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); | |
// Instantiating a Workbook object | |
Workbook workbook = new Workbook(); | |
// Obtaining the reference of the PageSetup of the worksheet | |
PageSetup pageSetup = workbook.Worksheets[0].PageSetup; | |
// Setting the printing order of the pages to over then down | |
pageSetup.Order = PrintOrderType.OverThenDown; | |
// Save the workbook. | |
workbook.Save(dataDir + "SetPageOrder_out.xls"); |