Formatera Pivot Tabellceller med C++
Contents
[
Hide
]
Ibland vill du formatera pivottabellceller. Till exempel vill du tillämpa bakgrundsfärg på pivottabellceller. Aspose.Cells tillhandahåller två metoder PivotTable::FormatAll() och PivotTable::Format(), som du kan använda för detta ändamål.
PivotTable::FormatAll() tillämpar stilen på hela pivot-tabellen medan PivotTable::Format() tillämpar stilen på en enskild cell i pivot-tabellen.
Följande exempel kod laddar den exempel fil som innehåller två pivot-tabeller, och utför operationen att formatera hela pivot-tabellen samt formatera individuella celler i pivot-tabellen.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main() {
Aspose::Cells::Startup();
Workbook workbook(u"pivot_format.xlsx");
Worksheet worksheet = workbook.GetWorksheets().Get(u"Sheet1");
PivotTable pivotTable = worksheet.GetPivotTables().Get(1);
Style style = workbook.CreateStyle();
style.SetPattern(BackgroundType::Solid);
style.SetBackgroundColor(Color::LightBlue());
pivotTable.FormatAll(style);
style = workbook.CreateStyle();
style.SetPattern(BackgroundType::Solid);
style.SetBackgroundColor(Color::Yellow());
PivotTable pivotTable2 = worksheet.GetPivotTables().Get(0);
pivotTable2.Format(16, 5, style);
workbook.Save(u"out.xlsx");
Aspose::Cells::Cleanup();
return 0;
}