ページ設定機能

場合によっては、印刷を制御するためにワークシートのページ設定を構成する必要があります。これらのページ設定の設定には、さまざまなオプションがあります。

ページ オプション

todo:画像_代替_文章

ページ設定オプションは、Aspose.Cells で完全にサポートされています。この記事では、Aspose.Cells でページ オプションを設定する方法について説明します。

ページ オプションの設定

Aspose.Cells はクラスを提供し、ワークブック、Microsoft Excel ファイルを表します。 Workbook クラスには、Excel ファイル内の各ワークシートへのアクセスを可能にする Worksheets コレクションが含まれています。ワークシートは、ワークシートクラス。

Worksheet クラスは、ページ設定オプションを設定するために使用される PageSetup プロパティを提供します。実際、PageSetup プロパティは、印刷されるワークシートのページ レイアウト オプションを設定できるようにする PageSetup クラスのオブジェクトです。 PageSetup クラスは、ページ設定オプションを設定するために使用されるさまざまなプロパティを提供します。これらのプロパティのいくつかを以下で説明します。

ページの向き

ページの向きは、ページ設定クラス'setOrientation(PageOrientationType)方法。のsetOrientation(PageOrientationType)メソッドはPageOrientationTypeパラメータとしての列挙。のメンバーPageOrientationType以下に列挙します。

ページの向きの種類 説明
風景 横向き
ポートレート 縦向き
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(PageOrientation.class) + "worksheets/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the first worksheet in the Excel file
WorksheetCollection worksheets = workbook.getWorksheets();
int sheetIndex = worksheets.add();
Worksheet sheet = worksheets.get(sheetIndex);
// Setting the orientation to Portrait
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setOrientation(PageOrientationType.PORTRAIT);
workbook.save(dataDir + "PageOrientation_out.xls");

スケーリング係数

倍率を調整して、ワークシートのサイズを縮小または拡大することができます。setZoomの方法ページ設定クラス。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(ScalingFactor.class) + "worksheets/";
// Instantiating a Excel object
Workbook workbook = new Workbook();
// Accessing the first worksheet in the Excel file
WorksheetCollection worksheets = workbook.getWorksheets();
int sheetIndex = worksheets.add();
Worksheet sheet = worksheets.get(sheetIndex);
// Setting the scaling factor to 100
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setZoom(100);
workbook.save(dataDir + "ScalingFactor_out.xls");

FitToPages オプション

ワークシートの内容を特定のページ数に合わせるには、ページ設定クラス'setFitToPagesTallsetFitToPagesWideメソッド。これらのメソッドは、ワークシートのスケーリングにも使用されます。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(FitToPagesOptions.class) + "worksheets/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the first worksheet in the Excel file
WorksheetCollection worksheets = workbook.getWorksheets();
int sheetIndex = worksheets.add();
Worksheet sheet = worksheets.get(sheetIndex);
PageSetup pageSetup = sheet.getPageSetup();
// Setting the number of pages to which the length of the worksheet will be spanned
pageSetup.setFitToPagesTall(1);
// Setting the number of pages to which the width of the worksheet will be spanned
pageSetup.setFitToPagesWide(1);
workbook.save(dataDir + "FitToPagesOptions_out.xls");

用紙サイズ

を使用して、ワークシートが印刷される用紙サイズを設定します。ページ設定クラス'用紙サイズ財産。 PaperSize プロパティは、用紙サイズの種類以下に列挙します。

用紙サイズの種類 説明
紙10x14 10インチ×14インチ。
紙11x17 11インチ×17インチ。
論文A3 A3(297mm×420mm)
用紙A4 A4(210mm×297mm)
紙A4小 A4小(210mm×297mm)
論文A5 A5(148mm×210mm)
論文B3 B3(13.9×19.7インチ)
紙B4 B4(250mm×354mm)
紙B5 B5(182mm×257mm)
紙ビジネスカード 名刺(90mm×55mm)
紙Cシート Cサイズシート
紙Dシート Dサイズシート
紙封筒10 封筒 #10 (4-1/8 インチ x 9-1/2 インチ)
紙封筒11 封筒 #11 (4-1/2 インチ x 10-3/8 インチ)
紙封筒12 封筒 #12 (4-1/2 インチ x 11 インチ)
紙封筒14 封筒 #14 (5 インチ x 11-1/2 インチ)
紙封筒9 封筒 #9 (3-7/8 インチ x 8-7/8 インチ)
紙封筒B4 封筒 B4 (250mm x 353mm)
紙封筒B5 封筒 B5 (176mm x 250mm)
紙封筒B6 封筒B6(176mm×125mm)
紙封筒C3 封筒 C3 (324 mm x 458 mm)
紙封筒C4 封筒 C4 (229mm x 324mm)
紙封筒C5 封筒 C5 (162 mm x 229 mm)
紙封筒C6 封筒 C6 (114 mm x 162 mm)
紙封筒C65 封筒 C65 (114mm x 229mm)
紙封筒DL 封筒 DL (110mm x 220mm)
紙封筒イタリア 封筒 イタリア (110 mm x 230 mm)
紙封筒モナーク 封筒モナーク (3-7/8 インチ x 7-1/2 インチ)
紙封筒個人 封筒 (3-5/8 インチ x 6-1/2 インチ)
紙Eシート Eサイズシート
ペーパーエグゼクティブ エグゼクティブ (7-1/2 インチ x 10-1/2 インチ)
PaperFanfoldLegalドイツ語 ドイツ リーガル ファンフォールド (8-1/2 インチ x 13 インチ)
PaperFanfoldStdGerman ドイツ標準折り紙 (8-1/2 インチ x 12 インチ)
PaperFanfoldUS 米国標準の連続紙 (14-7/8 インチ x 11 インチ)
ペーパーフォリオ フォリオ (8-1/2 インチ x 13 インチ)
ペーパーレジャー 元帳 (17 インチ x 11 インチ)
紙法務 リーガル (8-1/2 インチ x 14 インチ)
紙の手紙 レター (8-1/2 インチ x 11 インチ)
紙手紙小 レター小 (8-1/2 インチ x 11 インチ)
ペーパーノート メモ (8-1/2 インチ x 11 インチ)
ペーパークォート 四つ折り(215mm×275mm)
論文声明 ステートメント (5-1/2 インチ x 8-1/2 インチ)
紙タブロイド タブロイド (11 インチ x 17 インチ)
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(ManagePaperSize.class) + "worksheets/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the first worksheet in the Excel file
WorksheetCollection worksheets = workbook.getWorksheets();
int sheetIndex = worksheets.add();
Worksheet sheet = worksheets.get(sheetIndex);
// Setting the paper size to A4
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setPaperSize(PaperSizeType.PAPER_A_4);
workbook.save(dataDir + "ManagePaperSize_out.xls");

印刷品質

で印刷するワークシートの印刷品質を設定します。ページ設定クラス'setPrintQuality方法。印刷品質の測定単位は、1 インチあたりのドット数 (DPI) です。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(SetPrintQuality.class) + "worksheets/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the first worksheet in the Excel file
WorksheetCollection worksheets = workbook.getWorksheets();
int sheetIndex = worksheets.add();
Worksheet sheet = worksheets.get(sheetIndex);
// Setting the print quality of the worksheet to 180 dpi
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setPrintQuality(180);
workbook.save(dataDir + "SetPrintQuality_out.xls");

最初のページ番号

を使用して、ワークシート ページの番号付けを開始します。ページ設定クラス'setFirstPageNumber方法。 setFirstPageNumber メソッドは、最初のワークシート ページのページ番号を設定し、以降のページは昇順で番号付けされます。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(SetFirstPageNumber.class) + "worksheets/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the first worksheet in the Excel file
WorksheetCollection worksheets = workbook.getWorksheets();
int sheetIndex = worksheets.add();
Worksheet sheet = worksheets.get(sheetIndex);
// Setting the first page number of the worksheet pages
PageSetup pageSetup = sheet.getPageSetup();
pageSetup.setFirstPageNumber(2);
workbook.save(dataDir + "SetFirstPageNumber_out.xls");

マージンの設定

Aspose.Cells は Microsoft Excel のページ設定オプションを完全にサポートします。開発者は、印刷プロセスを制御するためにワークシートのページ設定を構成する必要がある場合があります。このトピックでは、Aspose.Cells を使用してページの余白を構成する方法について説明します。

Microsoft Excel のページ余白

todo:画像_代替_文章

Aspose.Cells はクラスを提供し、ワークブックMicrosoft Excel ファイルを表します。 Workbook クラスには、Excel ファイル内の各ワークシートへのアクセスを可能にする Worksheets コレクションが含まれています。ワークシートは、ワークシートクラス。

Worksheet クラスは、ページ設定オプションを設定するために使用される PageSetup プロパティを提供します。 PageSetup 属性は、ページ設定印刷されたワークシートにさまざまなページ レイアウト オプションを設定できるようにするクラス。 PageSetup クラスは、ページ設定オプションの設定に使用されるさまざまなプロパティとメソッドを提供します。

ページ余白

ページの余白 (上下左右) を設定するページ設定クラスのメンバー。ページ余白を指定するために使用されるいくつかの方法を以下に示します。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(SetMargins.class) + "worksheets/";
// Create a workbook object
Workbook workbook = new Workbook();
// Get the worksheets in the workbook
WorksheetCollection worksheets = workbook.getWorksheets();
// Get the first (default) worksheet
Worksheet worksheet = worksheets.get(0);
// Get the pagesetup object
PageSetup pageSetup = worksheet.getPageSetup();
// Set bottom,left,right and top page margins
pageSetup.setBottomMargin(2);
pageSetup.setLeftMargin(1);
pageSetup.setRightMargin(1);
pageSetup.setTopMargin(3);
workbook.save(dataDir + "SetMargins_out.xls");

ページの中央に配置

ページの水平方向と垂直方向の中央に何かを配置することができます。のページ設定クラスには、この目的のためのメンバーがあります。setCenterHorizontallysetCenterVertically.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(CenterOnPage.class) + "worksheets/";
// Create a workbook object
Workbook workbook = new Workbook();
// Get the worksheets in the workbook
WorksheetCollection worksheets = workbook.getWorksheets();
// Get the first (default) worksheet
Worksheet worksheet = worksheets.get(0);
// Get the pagesetup object
PageSetup pageSetup = worksheet.getPageSetup();
// Set bottom,left,right and top page margins
pageSetup.setCenterHorizontally(true);
pageSetup.setCenterVertically(true);
workbook.save(dataDir + "CenterOnPage_out.xls");

ヘッダーとフッターの余白

でヘッダーとフッターの余白を設定するページ設定などのメンバーsetHeaderMarginsetFooterMargin.

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(HeaderAndFooterMargins.class) + "worksheets/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the first worksheet in the Excel file
WorksheetCollection worksheets = workbook.getWorksheets();
int sheetIndex = worksheets.add();
Worksheet sheet = worksheets.get(sheetIndex);
PageSetup pageSetup = sheet.getPageSetup();
// Specify Header / Footer margins
pageSetup.setHeaderMargin(2);
pageSetup.setFooterMargin(2);
workbook.save(dataDir + "HeaderAndFooterMargins_out.xls");

ヘッダーとフッターの設定

ヘッダーとフッターは、ページの上マージンの上または下マージンの下にあるテキストと画像のセクションです。ワークシートにヘッダーとフッターを追加することもできます。ヘッダーとフッターを使用して、ページ番号、著者名、ドキュメントのタイトル、日付と時刻など、あらゆる種類の有用な情報を表示できます。ヘッダーとフッターも [ページ設定] ダイアログを使用して管理されます。

ページ設定ダイアログ

todo:画像_代替_文章

Aspose.Cells では、実行時にヘッダーとフッターをワークシートに追加できますが、ヘッダーとフッターは印刷用に事前に設計されたファイルに手動で設定することをお勧めします。 Microsoft Excel を GUI ツールとして使用すると、ヘッダーとフッターを簡単に設定して開発時間を短縮できます。 Aspose.Cells は、ファイルをインポートして、これらの設定を予約できます。

実行時にヘッダーとフッターを追加するために、Aspose.Cells はフォーマットを制御する特別なクラスといくつかのスクリプト コマンドを提供します。

スクリプト コマンド

スクリプト コマンドは、Aspose.Cells が提供する特別なコマンドで、開発者がヘッダーとフッターをフォーマットできるようにします。

スクリプト コマンド 説明
&P 現在のページ番号。
&G 絵。
&N 総ページ数。
&D 現在の日付。
&T 現在の時刻。
&A ワークシートの名前。
&F パスなしのファイル名。
&"<FontName>" フォント名。例: &“Arial”
&"<FontName>, <FontStyle>" スタイルのあるフォント名。例: &“Arial,Bold”
&<FontSize> フォントサイズを表します。例: 「&14abc」。ただし、このコマンドの後にヘッダーに印刷されるプレーンな数字が続く場合、これはフォント サイズからスペース文字で区切られる必要があります。例: 「&14 123」。

ヘッダーとフッターを設定する

ページ設定クラスはメソッドを提供します[setHeader](https://reference.aspose.com/cells/java/com.aspose.cells/pagesetup#setHeader(int,%20java.lang.String) ヘッダーを追加し、setFooter ワークシートにフッターを追加します。スクリプトは、上記のすべてのメソッドの引数として使用されます。ヘッダーまたはフッターに使用されるスクリプトを表します。このスクリプトには、ヘッダーまたはフッターをフォーマットするためのスクリプト コマンドが含まれています。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(SetHeadersAndFooters.class) + "worksheets/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Obtaining the reference of the PageSetup of the worksheet
PageSetup pageSetup = workbook.getWorksheets().get(0).getPageSetup();
// Setting worksheet name at the left header
pageSetup.setHeader(0, "&A");
// Setting current date and current time at the central header and changing the font of the header
pageSetup.setHeader(1, "&\"Times New Roman,Bold\"&D-&T");
// Setting current file name at the right header and changing the font of the header
pageSetup.setHeader(2, "&\"Times New Roman,Bold\"&12&F");
// Setting a string at the left footer and changing the font of the footer
pageSetup.setFooter(0, "Hello World! &\"Courier New\"&14 123");
// Setting picture at the central footer
pageSetup.setFooter(1, "&G");
FileInputStream fis = new FileInputStream(dataDir + "footer.jpg");
byte[] picData = new byte[fis.available()];
fis.read(picData);
pageSetup.setFooterPicture(1, picData);
fis.close();
// Setting the current page number and page count at the right footer
pageSetup.setFooter(2, "&Pof&N");
workbook.save(dataDir + "SetHeadersAndFooters_out.xls");

グラフィックをヘッダーまたはフッターに挿入する

ページ設定クラスにはメソッドがあります[setHeadPicture](https://reference.aspose.com/cells/java/com.aspose.cells/pagesetup#setHeaderPicture(int,%20byte[]) ) とsetFooterPicture ワークシートのヘッダーとフッターに画像を追加します。これらのメソッドは、次の 2 つのパラメーターを取ります。

  • セクション、画像が配置されるヘッダーまたはフッターのセクション。左、中央、右の 3 つのセクションがあり、それぞれ数値 0、1、2 で表されます。
  • ファイル入力ストリーム、グラフィックデータ。バイナリ データは、バイト配列のバッファーに書き込む必要があります。

コードを実行してファイルを開いた後、Microsoft Excel でワークシートのヘッダーを確認します。

  1. 上でファイルメニュー、選択ページ設定.
  2. [ページ設定] ダイアログで、ヘッダー/フッタータブ。

ヘッダー/フッターへのグラフィックの挿入

todo:画像_代替_文章

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(InsertImageInHeaderFooter.class) + "worksheets/";
// Creating a Workbook object
Workbook workbook = new Workbook();
// Creating a string variable to store the url of the logo/picture
String logo_url = dataDir + "school.jpg";
// Creating the instance of the FileInputStream object to open the logo/picture in the stream
FileInputStream inFile = new FileInputStream(logo_url);
// Creating a PageSetup object to get the page settings of the first worksheet of the workbook
PageSetup pageSetup = workbook.getWorksheets().get(0).getPageSetup();
// Setting the logo/picture in the central section of the page header
pageSetup.setHeader(1, "&G");
byte[] picData = new byte[inFile.available()];
inFile.read(picData);
pageSetup.setHeaderPicture(1, picData);
// Setting the Sheet's name in the right section of the page header with the script
pageSetup.setHeader(2, "&A");
// Saving the workbook
workbook.save(dataDir + "InsertImageInHeaderFooter_out.xls");
// Closing the FileStream object
inFile.close();

最初のページ ヘッダーのみにグラフィックを挿入する

ページ設定クラスには他にも便利なメソッドがあります。たとえば、セットピクチャー, setFirstPageHeader, setFirstPageFooter、ワークシートの最初のページのヘッダー/フッターに画像を追加します。最初のページは特別なページです。会社のロゴなど、特別な情報を表示したいのが一般的です。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(InsertGraphicinFirstPageHeaderOnly.class) + "worksheets/";
// Creating a Workbook object
Workbook workbook = new Workbook();
// Get the first worksheet (default).
Worksheet worksheet = workbook.getWorksheets().get(0);
// Adding some sample value to cells
Cells cells = worksheet.getCells();
Cell cell = cells.get("A1");
cell.setValue("Page1");
cell = cells.get("A60");
cell.setValue("Page2");
cell = cells.get("A113");
cell.setValue("Page3");
// Creating a PageSetup object to get the page settings of the first
// worksheet of the workbook
PageSetup pageSetup = worksheet.getPageSetup();
// Creating a string variable to store the url of the logo/picture
String logo_url = dataDir + "school.jpg";
// Creating the instance of the FileInputStream object to open the logo/picture in the stream
FileInputStream inFile = new FileInputStream(logo_url);
byte[] picData = new byte[inFile.available()];
inFile.read(picData);
// Setting the logo/picture in the right section of the first page header only
pageSetup.setHFDiffFirst(true);
pageSetup.setFirstPageHeader(2, "&G");
pageSetup.setPicture(true, false, true, 2, picData);
// Saving the workbook
workbook.save(dataDir + "IGInFirstPageHeaderOnly_out.xlsx");
// Closing the FileStream object
inFile.close();

印刷オプションの設定

Microsoft Excel のページ設定には、ユーザーがワークシート ページの印刷方法を制御できるいくつかの印刷オプション (シート オプションとも呼ばれます) が用意されています。これらの印刷オプションにより、ユーザーは次のことができます。

  • ワークシート上の特定の印刷領域を選択します。
  • タイトルを印刷します。
  • グリッド線を印刷します。
  • 行と列の見出しを印刷する
  • ドラフト品質を実現します。
  • コメントを印刷します。
  • セル エラーを出力します。
  • ページの順序を定義します。

これらの印刷オプションのすべてを以下に示します。

印刷 (シート) オプション

todo:画像_代替_文章

印刷オプションとシート オプションの設定

spose.Cells は、Microsoft Excel によって提供されるすべての印刷オプションをサポートし、開発者は、によって提供されるプロパティを使用して、ワークシートのこれらのオプションを簡単に構成できます。ページ設定クラス。これらのプロパティがどのように使用されるかについては、以下で詳しく説明します。

印刷範囲の設定

デフォルトでは、データを含むワークシートのすべての領域が印刷領域に組み込まれます。開発者は、ワークシートの特定の印刷領域を設定できます。

特定の印刷領域を選択するには、ページ設定クラス'setPrintArea財産。印刷領域を定義するセル範囲をこのプロパティに割り当てます。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(SetPrintArea.class) + "worksheets/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the first worksheet in the Workbook file
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet sheet = worksheets.get(0);
// Obtaining the reference of the PageSetup of the worksheet
PageSetup pageSetup = sheet.getPageSetup();
// Specifying the cells range (from A1 cell to T35 cell) of the print area
pageSetup.setPrintArea("A1:T35");
workbook.save(dataDir + "SetPrintArea_out.xls");

印刷タイトルの設定

Aspose.Cells を使用すると、印刷されたワークシートのすべてのページで行ヘッダーと列ヘッダーを繰り返すように指定できます。これを行うには、ページ設定クラス'setPrintTitleColumnssetPrintTitleRowsプロパティ。

繰り返される行または列は、行番号または列番号を渡すことによって定義されます。たとえば、行は $1:$2 として定義され、列は $A:$B として定義されます。

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(SetPrintTitle.class) + "worksheets/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the first worksheet in the Workbook file
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet sheet = worksheets.get(0);
// Obtaining the reference of the PageSetup of the worksheet
PageSetup pageSetup = sheet.getPageSetup();
// Defining column numbers A & B as title columns
pageSetup.setPrintTitleColumns("$A:$B");
// Defining row numbers 1 & 2 as title rows
pageSetup.setPrintTitleRows("$1:$2");
// Save the workbook.
workbook.save(dataDir + "SetPrintTitle_out.xls");

その他の印刷オプションの設定

ページ設定クラスには、次のような一般的な印刷オプションを設定するためのその他のプロパティもいくつか用意されています。

  • setPrintGridlinesは、グリッド線を印刷するかどうかを定義するブール型のプロパティです。
  • setPrintHeadings行と列の見出しを印刷するかどうかを定義するブール型のプロパティです。
  • setBlackAndWhiteは、ワークシートを白黒モードで印刷するかどうかを定義するブール型のプロパティです。
  • setPrintComments、ワークシートまたはワークシートの最後に印刷コメントを表示するかどうかを定義します。
  • setPrintDraftは、ワークシートを下書き品質で印刷するかどうかを定義するブール型のプロパティです。
  • setPrintErrorsは、セル エラーを表示、空白、ダッシュ、または N/A として出力するかどうかを定義します。

を設定するには印刷コメント印刷エラープロパティ、Aspose.Cells は 2 つの列挙も提供します。PrintCommentsTypePrintErrorsTypeに割り当てられる定義済みの値が含まれています。setPrintCommentssetPrintErrorsプロパティ。

の定義済みの値PrintCommentsType列挙については後述します。

印刷コメントの種類 説明
PRINT_IN_PLACE ワークシートに表示されているコメントを印刷するように指定します。
PRINT_NO_COMMENTS コメントを印刷しないように指定します。
PRINT_SHEET_END ワークシートの最後にコメントを印刷するように指定します。

の定義済みの値PrintErrorsType列挙については後述します。

印刷エラーの種類 説明
PRINT_ERRORS_BLANK エラーを出力しないように指定します。
PRINT_ERRORS_DASH エラーを「–」として出力するように指定します。
PRINT_ERRORS_DISPLAYED エラーを表示どおりに印刷するように指定します。
PRINT_ERRORS_NA エラーを「#N/A」として出力するように指定します。
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(OtherPrintOptions.class) + "worksheets/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the first worksheet in the Workbook file
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet sheet = worksheets.get(0);
// Obtaining the reference of the PageSetup of the worksheet
PageSetup pageSetup = sheet.getPageSetup();
// Allowing to print gridlines
pageSetup.setPrintGridlines(true);
// Allowing to print row/column headings
pageSetup.setPrintHeadings(true);
// Allowing to print worksheet in black & white mode
pageSetup.setBlackAndWhite(true);
// Allowing to print comments as displayed on worksheet
pageSetup.setPrintComments(PrintCommentsType.PRINT_IN_PLACE);
// Allowing to print worksheet with draft quality
pageSetup.setPrintDraft(true);
// Allowing to print cell errors as N/A
pageSetup.setPrintErrors(PrintErrorsType.PRINT_ERRORS_NA);
workbook.save(dataDir + "OtherPrintOptions_out.xls");

ページの順序を設定する

ページ設定クラスが提供するsetOrderワークシートの複数ページの印刷を注文するために使用されるプロパティ。ページを次のように並べ替えるには、次の 2 つの方法があります。

  • ダウン・アンド・オーバー右側のページを印刷する前に、すべてのページを下に印刷します。
  • オーバー・アンド・ダウン下のページを印刷する前に、ページを左から右に印刷します。

Aspose.Cells は列挙を提供し、PrintOrderTypeに割り当てられるすべての事前定義された注文タイプを含むsetOrder方法。

の定義済みの値PrintOrderType列挙については後述します。

印刷注文の種類 説明
DOWN_THEN_OVER 印刷してから重ねます。
OVER_THEN_DOWN 重ねてから下に印刷します。
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
String dataDir = Utils.getSharedDataDir(SetPageOrder.class) + "worksheets/";
// Instantiating a Workbook object
Workbook workbook = new Workbook();
// Accessing the first worksheet in the Workbook file
WorksheetCollection worksheets = workbook.getWorksheets();
Worksheet sheet = worksheets.get(0);
// Obtaining the reference of the PageSetup of the worksheet
PageSetup pageSetup = sheet.getPageSetup();
// Setting the printing order of the pages to over then down
pageSetup.setOrder(PrintOrderType.OVER_THEN_DOWN);
workbook.save(dataDir + "SetPageOrder_out.xls");

Excel ファイルのワークシートの既存の PrinterSettings を削除する

このトピックに関連するこの記事を参照してください。

先行トピック