C++を使用したページごとに異なるヘッダーとフッターの設定方法
Contents
[
Hide
]
MS Excelは、Excel 2007以降、最初のページ、奇数ページ、偶数ページの異なるヘッダーとフッターの設定をサポートしています。
Aspose.Cellsも同じ機能をサポートしています。
MS Excelで異なるヘッダーとフッターの設定
- ページレイアウト > 印刷タイトル > ヘッダー/フッターをクリックします。
- 奇数ページと偶数ページを異なるまたは最初のページだけを異なるをチェックします。
- 異なるヘッダーとフッターを入力します。
Aspose.Cellsで異なるヘッダーとフッターの設定
Aspose.CellsはExcelと同じように動作します。
- PageSetup.IsHFDiffOddEvenおよびPageSetup.IsHFDiffFirstのフラグを設定します。
- 異なるヘッダーとフッターを入力します。
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Create a new workbook
Workbook wb;
// Get the first worksheet's page setup
PageSetup pageSetup = wb.GetWorksheets().Get(0).GetPageSetup();
// Set different headers for odd and even pages
pageSetup.SetIsHFDiffOddEven(true);
pageSetup.SetHeader(1, u"I am the header of the Odd page.");
pageSetup.SetEvenHeader(1, u"I am the header of the Even page.");
// Set a different header for the first page
pageSetup.SetIsHFDiffFirst(true);
pageSetup.SetFirstPageHeader(1, u"I am the header of the First page.");
Aspose::Cells::Cleanup();
}