Build 4.5.0.15 of xlsgen improves pivot tables in a number of ways.
And this applies to XLS, XLSX, XLSB and ODS files.
-
custom number format : pivot fields can have a custom number format. xlsgen carries the number format from the data source by default, but it is now possible to customize it in the pivot table itself.
-
named range as datasource : before this build, the datasource needed to be a cell area. This still works, but it is now possible to pass a defined name, or a table name. The benefits of this is that by passing a name, the client application needs not know the boundaries of the data region.
-
"show values as" setting : for any pivot field in the data area, it is now possible to show values as is, or as difference from another field, or a percent, etc. You can pick one of
8 choices.
And here is a piece of source code (C++) that shows the above in practice :
xlsgen::IXlsWorksheetPtr wksht = wbk->AddWorksheet(L"Pivot2");
xlsgen::IXlsPivotTablePtr pt = wksht->NewPivotTable();
pt->DataSource->Range = L"Table4";
xlsgen::IXlsPivotTableFieldPtr pfSegment = pt->Rows->AddByName(L"Column1");
xlsgen::IXlsPivotTableFieldPtr pf1 = pt->Data->AddByName(L"q200");
pf1->NumberFormat = L"$###,###.00";
xlsgen::IXlsPivotTableFieldPtr pf2 = pt->Data->AddByName(L"q201");
xlsgen::IXlsPivotTableFieldPtr pf3 = pt->Data->AddByName(L"q202");
xlsgen::IXlsPivotTableFieldShowAsPtr pa2 = pf2->ShowValuesAs[xlsgen::pivotfieldshowas_differencefrom];
pa2->BasePivotField = pfSegment;
pa2->BasePivotItem = L"may";
pt->InsertAt(1,1);