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

Free Support Forum - aspose.com

Get the span of a pivot table (in columns)

How do you get the start and end columns on which a pivot table spans/is plotted? Essentially I need these to correctly position the pivot tables.

With functions such as pivotTable.TableRange I am able to see the column and row indices such as 6, 2 but I can also see something like B10:G12 i.e. actual Excel column headings (which is exactly what I want) but I can’t find any way of extracting these Excel headings!

Hi,


Thanks for your posting and using Aspose.Cells.

Please provide us your sample Excel file and sample code as well as a screenshot that should let us know what you want to extract with red circles around the area of your interest.

Thanks. I have solved this problem by implementing the following method:


private static string getpivotRHPoint(Worksheet nxtSheet)
{
//Get the RHS column index
int finCol = nxtSheet.PivotTables[0].ColumnRange.EndColumn;
//Get the actual Excel Heading letter
String finColHeading = getColumnNameFromIndex(finCol + 1);

//Get the last row index
int lastRow = nxtSheet.PivotTables[0].RowRange.EndRow;
//Join the Column letter to last row index to get the RHS endpoint of the pivot
string lastRHPoint = finColHeading + lastRow.ToString();
//Get the last point on the A column
String lastLHPoint = “A” + lastRow;
return lastRHPoint;
}

Regards
Hi,

Thanks for your feedback and using Aspose.Cells.

It is good to know that you were able to sort out your issue. Let us know if you encounter any other issue, we will be glad to look into it and help you further.