レポートフィルタページオプションをC++で表示
Contents
[
Hide
]
レポートフィルタページを表示
Excelはピボットテーブルの作成、レポートフィルタの追加、「レポートフィルタページを表示」オプションの有効化をサポートしています。Aspose.Cellsもこの機能をサポートしており、作成したピボットテーブルに対して「レポートフィルタページを表示」オプションの有効化が可能です。以下は、Excelでの「レポートフィルタページを表示」オプションのスクリーンショットです。
サンプルソースファイルと出力ファイルは、テスト用のサンプルコードをダウンロードできます:
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Source directory path
U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
// Output directory path
U16String outDir(u"..\\Data\\02_OutputDirectory\\");
// Load template file
Workbook wb(srcDir + u"samplePivotTable.xlsx");
// Get first pivot table in the worksheet
PivotTable pt = wb.GetWorksheets().Get(1).GetPivotTables().Get(0);
// Set pivot field
pt.ShowReportFilterPage(pt.GetPageFields().Get(0));
// Set position index for showing report filter pages
pt.ShowReportFilterPageByIndex(pt.GetPageFields().Get(0).GetPosition());
// Set the page field name
pt.ShowReportFilterPageByName(pt.GetPageFields().Get(0).GetName());
// Save the output file
wb.Save(outDir + u"outputSamplePivotTable.xlsx");
std::cout << "Pivot table report filter pages set successfully!" << std::endl;
Aspose::Cells::Cleanup();
}