PivotTables loop and set order

Hi,


Thanks for the demo, sample project and template files.

It looks like you are not using latest version/fix: Aspose.Cells for .NET v8.8.0.2 (download URL is already provided in my previous post) in your project. I have tested your scenario/ case using your new sample project with v8.8.0.2 and your original template file, it works fine and as expected. Please find attached the updated project (referenced with Aspose.Cells for .NET v8.8.0.2) and output Excel files for your reference. Please open the attached output Excel files if these are fine tuned.

Thank you.

“It looks like you are not using latest version/fix: Aspose.Cells for .NET v8.8.0.2 (download URL is already provided in my previous post) in your project.”


Yes i do…see property window in file “sshot-385.gif” of my last post

Ok i try your proj

Hello


I tried it again in another computer. Not working

book1_OUT_Asc an book1_OUT_Desc are identical

8.8.0.2 dll version

Same files that I have attached other times

If you want i can give you remote control of my machine to see the problem

Hi,

Well, now that is strange. It works fine on my end as you can see my attached output Excel files for confirmation. It should also work equally fine on your end using v8.8.0.2 (latest fix). Could you add a line to your code segment to get the version number of the Aspose.Cells assembly that your are using:
e.g.
Sample code:

...
MessageBox.Show(CellsHelper.GetVersion());
…

Also, please build (as it is) and run my attached project (you just need to edit the file paths before compiling the project in your VS.NET) and provide the output Excel files here. Also provide your updated project with v8.8.0 (you may zip it prior attaching here) and input file, so I could just run it and generate the output Excel files on my end as well.

Also, here is my environment Details:
OS: Windows 8, VS.NET 2010. Target .NET Framework version: 4.0, etc.

Please provide your environment details.

Thank you.

I delete my project and use yours… same problem,. Attach again


Fmk is in the project: 4.0. Other info in screenchots

Dll version: https://www.dropbox.com/s/xa2slccnsve4bbu/Aspose.Cells_20160511_102315.rar?dl=1

Please make sure you use my Excel file (attach again)

I create new Excel file just in case… same problem



Hi,


Thanks for providing us further details, sample project and screenshots.

Please use the attached “book1.xls” file to test your scenario/ case using your attached project, it works fine with it as I have tested. I have attached the “book1.xls” (which you previously attached the file) and output XLS files for your reference. After running the project with my attached "book1.xls"file, please generate the output XLS files after clicking on the third button (while selecting the item (on by one) from the drop down and attach the output XLS files here.

I also did test your project with your attached book1.xls and Book2.xlsx files and it does not work on my end this time.

Thank you.

Ok the problem is the Excel file… but Why?

I attach the two files to determine whats happend… Do you know it?

Most worring is that the second NEW excel file (book2.xlsx) have same problem

Hi,


Yes, it looks like template specific issue. I re-tested your issue using the same project with your newly attached XLS files and found that it does not work when using “book1_KO.xls” whereas it works as expected with “book1_OK.xls”. How did you create the file “book1_KO.xls”, did you manually create the Pivot Table in MS Excel or generated it by some tool or other APIs? Apparently both files are same but we have to evaluate the files internally, we will do so soon.

Thank you.

" How did you create the file “book1_KO.xls”, did you manually create the Pivot Table in MS Excel or generated it by some tool or other APIs? "


Normal method, no APIs:
- Inside folder right mouse button
- New/Excel file option

I create new fle Excel a test it. See attach demo video

Hi,


Thanks for providing us demo video.

I have a detailed discussion with the concerned developer from product team. We come to conclusion that you should always use the sample code as following (it might produce your desired results to some extent but not fully):
e.g
Sample code:

//Please change the name of the pivot table accordingly for your template file’s PivotTable in the worksheet.
PivotTable pt = _sheetActiva.PivotTables[“Tabla dinámica5”];
for (int i = 0; i < pt.RowFields.Count; i++)
{
pt.RowFields[i].IsAutoSort = true;
pt.RowFields[i].IsAscendSort = _bolOrdenAsc;
pt.RowFields[i].AutoSortField = -1;
}

There are two main things here which should be noted/considered:
1) You should always get PivotTable via its name and not by its indexed position. We noticed it because the PivotTable in two different files has different index numbers.
2) I am afraid, currently, we don’t support to apply data sorting based on Data fields in PivotTable report. In short, Aspose.Cells does not support data sorting via DataField. So, if you want to sort the PivotField by itself, you can use PivotField.IsAutoSort and PivotField.IsAscendSort to try to control the order. We have already logged a ticket to add support to sort data based on DataField into our database.

If you still could not evaluate and accomplish the task for your needs, kindly do provide us the original input file and your expected file (which you may create in MS Excel manually for your desired sort order in PivotTable), we will check it soon.

Thank you.
Hi,

"we don't support to apply data sorting based on Data fields in PivotTable report"

You're saying that what you said above is not correct?:
"_sheetActiva.PivotTables[0].RowFields[i].AutoSortField = 0;//Apply the sorting for the first data field.""


Then the order of pivot table not working?

" you can use PivotField.IsAutoSort and PivotField.IsAscendSort to try to control the order"..

Whats that? Order of entire document? I need to apply multiple order: first column in asc, second in desc, third in asc, etc...


Hi,

ageinfo:
"we don't support to apply data sorting based on Data fields in PivotTable report"

You're saying that what you said above is not correct?:
"_sheetActiva.PivotTables[0].RowFields[i].AutoSortField = 0;//Apply the sorting for the first data field.""

Yes, we are sorry for the confusion. Actually, the feature "Sort data in Data field with respect to / by Row pivot field in the PivotTable" is still not supported or implemented at the moment (see the reference thread: https://forum.aspose.com/t/65804)
We did log a ticket with an id "CELLSNET-43257" for the feature a year ago.

ageinfo:
Then the order of pivot table not working?

" you can use PivotField.IsAutoSort and PivotField.IsAscendSort to try to control the order"..

Whats that? Order of entire document? I need to apply multiple order: first column in asc, second in desc, third in asc, etc...

Could you provide us the original input file and your expected file (which you may create in MS Excel manually for your desired sort orders in PivotTable), we will check it soon.

Thank you.

Hello


I have ‘book2.xlsx’ and want ‘book2 - End.xlsx’

Please note in ’ book2 - End.xlsx’ i want to sort by ‘Suma de Sales1’ in descending mode
Hi,

Thanks for providing us your expected file containing the PivotTable with your desired sort order.

Well, as you need to sort data field with respect to row field in PivotTable (see the screenshot here: http://prntscr.com/b6a9we), but I am afraid, this feature is not supported. We already logged a ticket "CELLSNET-43257" for this unsupported feature. I have logged a ticket "CELLSNET-44451" for the task. We will check if we can provide you some workaround using Aspose.Cells APIs to accomplish your task. Once we devise a code snippet to achieve his desired results, we will share it with you here.

Keep in touch.

Thank you.

Hello


One idea… is possible to copy and paste the entirre sheet into another new sheet as VALUES (not pivot table). Then i can sort normally the columns as i want… or not? Can you paste the code for do it?

Hi,


I am afraid, there is no update on your issue logged earlier as “CELLSNET-44451”. I have asked the concerned developer from product team to update on it. Once we have an update on it, we will let you know here.

Regarding your recent query, well, you may try to create a range based your worksheet data/area and then paste values/data into other worksheet (after creating the destination range) using Range.CopyValue and Range.CopyData methods, see the documents for your reference:
http://www.aspose.com/docs/display/cellsnet/Copy+Range+Data+Only
http://www.aspose.com/docs/display/cellsnet/Copy+Range+Data+with+Style

Note: please don’t forget to call PivotTable.RefreshData() and PivotTable.CalculateData() methods before creating and copy/pasting ranges b/w worksheets.

Thank you.

Hi,

Thanks for using Aspose.Cells.

We are afraid, we can’t support sorting the PivotField via DataField. We will support it later, but we have no plan for it now.

Hello

Too complicated...
We'll wait for the version with this feature

@ageinfo,

Please try our latest version/fix: Aspose.Cells for .NET v19.11.8 (attached).

Your issue should be fixed in it.

Let us know your feedback.
Aspose.Cells19.11.8 For .Net2_AuthenticodeSigned.Zip (5.0 MB)
Aspose.Cells19.11.8 For .Net4.0.Zip (5.0 MB)

The issues you have found earlier (filed as CELLSNET-44451) have been fixed in Aspose.Cells for .NET v19.12. This message was posted using Bugs notification tool by Amjad_Sahi