Closed abhishekdattagit closed 3 years ago
Sure I can certainly take a look at that. Thinking about the API I'd probably need to introduce a Cell object and give it range/merged parameters which will be a different API. I need to look into the data to see how merges are encoded so might not be a quick fix.
Are you thinking horizontal as well as vertical merges? If you have an example spreadsheet you can share that will help in testing.
Jon
On 26 Jun 2021, at 05:23, abhishekdattagit @.***> wrote:
Thanks for this excellent little package. Would it be possible to support a cell API that supports querying for the "merged" attribute?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/masaccio/numbers-parser/issues/1, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABTU2VJ3LQJVCZ3FM4SC3SLTUVI4RANCNFSM47K6NHHQ.
@abhishekdattagit I've added a method cells() which returns Cell objects for the type of cell in the table. This includes MergedCell objects which represent cells that have been merged. I've found where Numbers stores the list of merged cells but I haven't figured out how to associate a list of merges with a particular table.
Thanks Jon. I am going to try the method and report back. The spreadsheet I am using just now has some privileged information, but I can create one with merged cells like it, if you are still interested in an example.
No need to share a document then. I've just pushed some additional changes to GitHub, but not to PyPI yet and these include some new methods. Basically the MergedCell objects (the removed 'empty' cells when a merge happens) have a merge_range which is the range of cells that cover the whole merge. The 'source' of the merge (the cell that remains) has an is_merged property that is True/False on whether the cell is merged.
tests/test_merges.py has loads of examples of the API and I'll refactor/document stuff this weekend
Would be great to hear if it works for you as the extracting of the merge ranges was the most complex reverse-engineering of the file format I've done to date and I am a little worried it might still be fragile.
Brilliant. This works for the cases I tried out as expected. Thanks Jon!
Thanks for this excellent little package. Would it be possible to support a cell API that supports querying for the "merged" attribute?