We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Column Label Headers Style in Pivot Table

Hi Team! Is there a way to custimize the column label headers in a pivot Table?

I tried the following but with no luck:

Aspose.Cells.Style stylePivot = workbook.CreateStyle();

stylePivot.HorizontalAlignment = TextAlignmentType.Bottom;

stylePivot.VerticalAlignment = TextAlignmentType.General;

stylePivot.SetBorder(BorderType.Vertical, CellBorderType.Thin, Color.Black);

pivotTable.FormatAll(stylePivot);

// Then I created a new style for some header columns (column label headers)

Aspose.Cells.Style styleRot = workbook.CreateStyle();

styleRot.RotationAngle = 70;

styleRot.BackgroundColor = Color.Red;

pivotTable.Format(3, 12, styleRot);

// or apply the style to several columns headers

for (int i = 11; i < 14; i++)

//{

// pivotTable.Format(3, i, DataStyle);

//}

But it didn't work. Based on other posts the Range.ApplyStyle isn't useful with pivot Tables. So I use Format method from Pivot Table API.

Is there a way to apply a style to column labels? Please check the attached file.

Thanks in Advance!

Regards!

Never mind, I figured it out. I added:

pivotTable.RefreshData();
pivotTable.CalculateData();

and it worked!!!

Regards!

Hi,


Good to know that you have sorted out by yourself.

And, sure you will always refresh the pivot table and calculate the pivot report data before applying the formattings.

Thank you.