Pivot Table - Change Data Source based on range

Dear all,

i’m looking for help on how to change data source of a specific pivot table (using an excel table).

My needs is to change the source of a preexisting pivot table based on a range of data that can be variable depending on a sql statement result.

so far i’ve this portion of code

PivotTableCollection pivotTables= sheet4.getPivotTables();
PivotTable totcompvt = pivotTables.get(“pivototcomp”);
PivotTable totcompvtmn = pivotTables.get(“pivototcompmn”);
PivotTable totcompvtbti = pivotTables.get(“pivototcompbti”);
range = sheet4.getCells().createRange(“V2”,CellsHelper.cellIndexToName(sheet4.getCells().getLastDataRow(21),21));
range.setName(“pvtRange”);

but, i don’t get how to use the changeDataSource method and link to my range (if possible)

In another topic i found (was for .net) and adapted this code but pivot doesn’t get updated

totcompvt.changeDataSource(new String[] {“pvtRange”});

Can you please help out on this?

thanks,
regards.

So far i’ve solved using data table instead of simple range.

But now i’ve another issue. as stated on previous post i’m using a template… when xlsx is created opening raise an error as xlsx is corrupted and needs repair.

after repair i got

Removed Part: /xl/tables/table4.xml part. (Table)

and xlsx loose some charts and slicers.

I saw in another post that this “bug” was solved within a new version of aspose cells.

My company provided me a licensed version 8.3.1. Is possible to have a fixing for my version?

thanks,
regards,

Hi Gabriele,


Thank you for contacting Aspose support.

It is good to know that you are able to resolve the problem mentioned in your original post. Regarding your recent concerns, I am afraid, it is not possible to fix a problem on the top of your current revision of the API. Reason being, we maintain single code base therefore any issue found in the API will be fixed in the most recent release.

If you are certain that your presented scenario is same as discussed in your referenced thread then you must give a try to the latest version to see if it actually fixes the issue. You may comment out your licensing statements to test in evaluation mode or request for a 30 day trial license to make sure that the problem has been rectified. Once you are satisfied with the output, you may negotiate with the Sale team to get your subscription renewed.

Hi Sialkot,

thanks for the feedback. I tested version 8.5.1 and problem get solved in that version.
I don’t manage licensing but we should renew our next month… i suppose we will get a bug free version after renewal.

regards,

Hi,

Thanks for your feedback and using Aspose.Cells.

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