Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP Pivot table calculated fields #885

Open
wants to merge 12 commits into
base: develop
Choose a base branch
from

Conversation

@b0bi79
Copy link
Member

b0bi79 commented Jun 4, 2018

Wow. You have already begun to implement this, perfectly. Can I help you here?

@igitur
Copy link
Member Author

igitur commented Jun 5, 2018

Thanks, but almost finished. Just need to figure out why sometimes the output file is corrupted.

@igitur igitur changed the title Pivot table calculated fields WIP Pivot table calculated fields Jun 5, 2018
@igitur igitur force-pushed the issue821-pivottables-corrupt branch 3 times, most recently from 4e12843 to ad49119 Compare June 6, 2018 14:20
@igitur igitur force-pushed the issue821-pivottables-corrupt branch 2 times, most recently from 528a42e to 759cebe Compare June 7, 2018 12:42
@igitur igitur force-pushed the issue821-pivottables-corrupt branch from 759cebe to e008615 Compare June 14, 2018 09:10
@igitur igitur added this to the v0.94 milestone Jun 14, 2018
@igitur igitur force-pushed the issue821-pivottables-corrupt branch 2 times, most recently from b08e8e7 to 98890e1 Compare July 5, 2018 20:30
@igitur
Copy link
Member Author

igitur commented Jul 5, 2018

@b0bi79 I must still add unit tests, but I think most of the pivot table calculated fields are now complete. You're welcome to test this branch and give feedback.

@igitur igitur force-pushed the issue821-pivottables-corrupt branch 2 times, most recently from 71ba76a to de4d6f5 Compare July 5, 2018 20:45
@b0bi79
Copy link
Member

b0bi79 commented Jul 6, 2018

Of course, Francois, I already started testing.

@b0bi79
Copy link
Member

b0bi79 commented Jul 6, 2018

The generated file does not open in the Excel and when loading ClosedXML an exception occurs.
Here generated file
11.xlsx

@b0bi79
Copy link
Member

b0bi79 commented Jul 6, 2018

I think that the calculated fields must be added to PivotCacheDefinition.CacheFields

@igitur
Copy link
Member Author

igitur commented Jul 6, 2018

OK, will fix it.

@b0bi79
Copy link
Member

b0bi79 commented Jul 6, 2018

I found. If there are two PivotTables in the workbook that have the same data source, but there is a calculated field in one pivot table, and the other table does not, PivotCacheDefinition.CacheFields may be incorrect.
Applied to the file 11.xlsx:

  1. When saving the first PivotTable in PivotCacheDefinition.CacheFields, a list of 8 items was created.
  2. When saving the second PivotTable, the PivotCacheDefinition.CacheFields list of 8 elements was replaced by a list of 7 elements

@igitur igitur force-pushed the issue821-pivottables-corrupt branch from 18fc8fe to 8b81f1b Compare July 8, 2018 16:29
@igitur
Copy link
Member Author

igitur commented Jul 8, 2018

I can't even load that file in Excel.

image

@b0bi79
Copy link
Member

b0bi79 commented Jul 8, 2018

Yes, I too. I created this file with ClosedXML. I added to this file two pivot tables that have one data source. To the first table added calculated field, and to the second table does not.
I found the cause of the error, see my previous comment.

Tomorrow I'll try to write a test that reproduces this issue.

@b0bi79
Copy link
Member

b0bi79 commented Jul 9, 2018

Test is very simple. I created one file with Excel . Just opening and saving this file in ClosedXML degrade this file.
tPivot5.xlsx

                using (var wb = new XLWorkbook("tPivot5.xlsx"))
                {
                    wb.SaveAs("d:\\temp\\pvt.xlsx");
                }

I saw what features are inside the xml in this file: the workbook.xml file has only one pivotCache element for all pivot tables in the workbook. ClosedXML on saving replaces pivotCache with invalid data.

@igitur
Copy link
Member Author

igitur commented Jul 9, 2018

@b0bi79 I see now. I think a separate issue to consolidate pivot tables with shared sources should be completed first.

@igitur igitur removed this from the v0.94 milestone Oct 12, 2018
@igitur igitur force-pushed the issue821-pivottables-corrupt branch from 8b81f1b to 78f326f Compare October 20, 2018 12:26
@michaelferry
Copy link

@igitur , is this still WIP? Is there a work around in the meantime for me to open spreadsheets with calculated fields in a pivot table?

@Pitterling
Copy link

@igitur , is this still WIP? Is there a work around in the meantime for me to open spreadsheets with calculated fields in a pivot table?

facing the same issue, preventing me from using newer ClosedXML version .. Pivot and Calculated Fields have always been in my excel, but now this part is not just skipped .... Thx

@igitur
Copy link
Member Author

igitur commented Jun 26, 2019

Yes, still WIP

@igitur igitur force-pushed the issue821-pivottables-corrupt branch from 78f326f to 76291df Compare June 27, 2019 10:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support calculated fields Crash when opening file containing a pivot table with calculated fields.
4 participants