Closed ghiscoding closed 3 months ago
Run & review this pull request in StackBlitz Codeflow.
All modified and coverable lines are covered by tests :white_check_mark:
Project coverage is 99.8%. Comparing base (
21d8d4c
) to head (2e56902
). Report is 5 commits behind head on master.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
@zewa666 So I know we talked about this a while ago and I always wanted to eventually go in depth on the subject to see if it's doable to use Formula in Excel Export by using other props of the item data context, so here it is... just because.... we can 🚀 😆
Note that I was missing the dataContext
argument in excelExportOptions.valueParserCallback
, so I added it in here and tagged this PR as a feature because I don't think it would have been possible to do without the data context in this case (meaning creating a formula by using other props of the data context)
cc @jr01
damn don't show this to my boss 🤣
need to take some proper time to check this PR out but so far this looks amazing
@zewa666 cherry on top 🍒, I even got the demo to calculate Grouping Totals Sum (see both print screens above), your boss really shouldn't see this lol 🚀
However please note that it takes a fair amount of code to get it all working, I also assume that perf is probably impacted as well a bit, but anyway the point was to show that it's possible. I assume that generic functions and code reuse should help to decrease the number of lines, I know that I have repeated code and that is to keep it readable and understandable by the users who looks at the code. Also another thing to note, I got it working for Group Sum with 1 group level depth, it would be much harder to implement with multiple depth (and that has to be implemented by the user like in the new demo)
Final note, I had to add couple more arguments to valueParserCallback
and considering that we now 7 arguments to the callback, I am planning to regroup some of these arguments into a single arg object for simplicity and also easier to extend in the future. I know it's a breaking change but I'd be surprised if anyone started using valueParserCallback
since it's a very custom way to export to Excel and new major wasn't long ago so not that many migrated yet too, so I will do that in another PR in the coming days, so don't go crazy on using it just yet 😉
At this point, even Ag-Grid doesn't even provide such custom export, I should be paid a large amount of money for this feature, but to be fair I'm not even sure anyone would go that deep in their Excel export customization 😆
so much good stuff in this example. I didnt know about setting the metadata for excel exports. thats really great. where can I read up on the options? do you perhaps have a link?
@zewa666 indeed you can do a lot with the cell value parser, I updated the associated cell value parser docs, you can find some info there. But I got a lot of these ideas when I migrated Excel-Builder to native code, for example the Excel Formulas I really got it from there when I read more about the metadata, so you'll get more info by going to the excel-builder-vanilla repo, read the docs and also try all the demos which I purposely made them WYSIWYG (what you see in the UI, you'll get in the export). In summary, whatever you can do in Excel-Builder, you should be able to do in SlickGrid as well 🚀
excelExportOptions.valueParserCallback
was missing the dataContext which can be useful when the exported data is not the current cell value but another cell value, for example our cell is Total but is a calculated value from 2 other column dataContext (Price & Qty)excelExportOptions.style
wasn't being applied on regular data cellexcelExportOptions.valueParserCallback
)TODOs
excelExportOptions.filename
doesn't seem to work, need to investigategroupTotalsExcelExportOptions
which I had to improve to do everything I wanted in this demo :)use Excel Formulas to calculate Totals by using other dataContext props
use Excel Formulas to calculate Group Totals