C++でワークシートの用紙サイズが自動かどうかを判断する
Contents
[
Hide
]
可能な使用シナリオ
ほとんどの場合、ワークシートの用紙サイズは自動設定です。自動の場合、多くはレターに設定されています。ユーザーが設定した場合は自動ではありません。Worksheet
クラスのPageSetup.IsAutomaticPaperSizeプロパティを使って紙のサイズが自動かどうかを調べることができます。
ワークシートの用紙サイズが自動かどうかを判断する
以下のサンプルコードは、次の2つのExcelファイルをロードし
そして最初のワークシートの用紙サイズが自動かどうかを確認します。Microsoft Excelでは、ページ設定ウインドウを通じて用紙サイズが自動かどうかを確認できます。
サンプルコード
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C
// Source directory path
U16String sourceDir(u"..\\Data\\01_SourceDirectory\\");
// Load the first workbook having automatic paper size false
Workbook wb1(sourceDir + u"samplePageSetupIsAutomaticPaperSize-False.xlsx");
// Load the second workbook having automatic paper size true
Workbook wb2(sourceDir + u"samplePageSetupIsAutomaticPaperSize-True.xlsx");
// Access the 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
std::wcout << u"First Worksheet of First Workbook - IsAutomaticPaperSize: " << ws11.GetPageSetup().IsAutomaticPaperSize() << std::endl;
std::wcout << u"First Worksheet of Second Workbook - IsAutomaticPaperSize: " << ws12.GetPageSetup().IsAutomaticPaperSize() << std::endl;
Aspose::Cells::Cleanup();
}
コンソール出力
上記のサンプルコードを指定されたサンプルExcelファイルで実行したときのコンソール出力は次の通りです。
First Worksheet of First Workbook - IsAutomaticPaperSize: False
First Worksheet of Second Workbook - IsAutomaticPaperSize: True