How can I vertically center a value in a PivotTable cell with Aspose Cells?

Hello,

I asked this question on stackOverflow here but have been hearing a cricket chorus over there.

So I'll put it here:

I know how to vertically center cell values when they can be defined by their row location, namely get a reference to them, create a style, assign values to the style, and then assign the style to the cell, like so:

cell = pivotTableSheet.Cells[4, 0];
cell.PutValue(AnnualContractProductsLabel);
style = cell.GetStyle();
style.HorizontalAlignment = TextAlignmentType.Center;
style.VerticalAlignment = TextAlignmentType.Center;
style.Font.IsBold = true;
pivotTableSheet.Cells.SetRowHeight(4, 25);
style.BackgroundColor = CONTRACT_ITEM_COLOR;
pivotTableSheet.Cells[4, 0].SetStyle(style);

But what about for recurring values, such as those that are generated for a PivotTable?

I create a row value like so:

pivotTable.AddFieldToArea(Aspose.Cells.Pivot.PivotFieldType.Row, DESCRIPTION_COLUMN);
pivotTable.RowHeaderCaption = "Description";

...which appears like this (the values beneath "Description" such as "Anise, *" and "Artichokes, *", "Asparagus, *" etc.):

[ the question on StackOverflow has a screenshot; I couldn't figure out how to add it here, although I did upload it. ]


I want those values vertically centered, rather than at the top. How can I manage that?

BTW, I posted a tip on using Aspose Cells to create a Pivot Table here.

Hi Clay,


Thank you for contacting Aspose support.

Just to be sure that I have understood your requirements, please check the attached sample.xlsx for a Pivot Table. I believe you wish to merge the cells F11:F13 and then vertically align the contents to center. If this is correct, I am afraid, this cannot be accomplished with Aspose.Cells or Excel application. Reason being, Excel does not allow to merge the ranges within a Pivot Table. If you try to do so manually, Excel will pop-up a warning similar to attached snapshot. If you meant something else, I would request you to please provide the input spreadsheet as well as your desired results that you may create manually in Excel to show what you need to accomplish.