Am trying to set the background colour of the pivot fields of a pivot table (see the attachment) using Aspose.cells for .NET.
The following code only set the colour of the header/caption but I want to set the colour of the entire pivotfield column:
var workbook = new Workbook(“C:\Temp\PivotTableSample.xlsx”);
var worksheet = workbook.Worksheets[0];
var pivotTable = worksheet.PivotTables[0];
// workbook.CalculateFormula();
pivotTable.RefreshData();
pivotTable.CalculateData();
//Specify Find options
FindOptions opts = new FindOptions();
opts.SearchNext = true;
opts.LookInType = LookInType.Values;
opts.LookAtType = LookAtType.Contains;
//Find your header cell
Cell cell = worksheet.Cells.Find(“Sum of Sales Amount”, null, opts);
if (cell != null)
{
Style style = cell.GetStyle();
style.ForegroundColor = Color.Yellow;
style.Pattern = BackgroundType.Solid;
cell.SetStyle(style);
}
workbook.Save(“C:\Temp\outexample2.xlsx”);