ワークシートの用紙サイズが自動かどうかを判断する
Contents
[
Hide
]
考えられる使用シナリオ
ほとんどの場合、ワークシートの用紙サイズは自動です。自動の場合は、次のように設定されることがよくあります手紙.ユーザーは、必要に応じてワークシートの用紙サイズを設定することがあります。この場合、用紙サイズは自動ではありません。ワークシートの用紙サイズが自動かどうかを確認するには、Worksheet.getPageSetup().isAutomaticPaperSize()方法。
ワークシートの用紙サイズが自動かどうかを判断する
以下のサンプル コードは、次の 2 つの Excel ファイルを読み込みます。
最初のワークシートの用紙サイズが自動かどうかを調べます。 Microsoft Excel では、このスクリーンショットに示すように、[ページ設定] ウィンドウで用紙サイズが自動かどうかを確認できます。
サンプルコード
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 | |
// Load the first workbook having automatic paper size false | |
Workbook wb1 = new Workbook(srcDir + "samplePageSetupIsAutomaticPaperSize-False.xlsx"); | |
// Load the second workbook having automatic paper size true | |
Workbook wb2 = new Workbook(srcDir + "samplePageSetupIsAutomaticPaperSize-True.xlsx"); | |
// Access first worksheet of both workbooks | |
Worksheet ws11 = wb1.getWorksheets().get(0); | |
Worksheet ws12 = wb2.getWorksheets().get(0); | |
// Print the PageSetup.IsAutomaticPaperSize property of both worksheets | |
System.out.println("First Worksheet of First Workbook - IsAutomaticPaperSize: " + ws11.getPageSetup().isAutomaticPaperSize()); | |
System.out.println("First Worksheet of Second Workbook - IsAutomaticPaperSize: " + ws12.getPageSetup().isAutomaticPaperSize()); |
コンソール出力
以下は、指定されたサンプル Excel ファイルで実行されたときの上記のサンプル コードのコンソール出力です。
First Worksheet of First Workbook - IsAutomaticPaperSize: false
First Worksheet of Second Workbook - IsAutomaticPaperSize: true