numbers-parser icon indicating copy to clipboard operation
numbers-parser copied to clipboard

Incorrect rows order returned for grouped tables

Open ibrahimabdo opened this issue 8 months ago • 3 comments

Hello,

Describe the bug Trying to access rows and columns in a table with group categories returns different results than the expected ones.

To Reproduce

doc = Document("test.numbers")
print(doc.sheets[0].tables[1].cell("B8").formatted_value)

Expected behavior The above code should print Dinner with Friends (the expected value from the B8 column in the table with group categories), but it prints Medicine (the value that was in the table at B8 before applying the categories)

Attachments test.numbers.zip

Thank you!

ibrahimabdo avatar May 29 '25 06:05 ibrahimabdo

Reproduced.

Groups are complicated in how they are stored and I've not looked at that yet, so it may take time depending upon how complex the data structures in the Numbers files are.

masaccio avatar Jun 03 '25 12:06 masaccio

What's your use case for using cell("B8") versus cell(7, 1)? I ask because the formula ROW() in a grouped table doesn't return the row number of that table, but instead the row number of the original row before the grouping happened. Same goes for other formulas, so MATCH() searches the original table.

So I'd like to get the specific case done first before I do the general one which will need to support multiple data types like dates and also nested groups.

masaccio avatar Jun 06 '25 14:06 masaccio

Hello, Thank you for looking into this!

I'm not sure if my answer is very helpful or pretty vague, but I was working on a tool where users would have to reference some cells in their .numbers file in order to do some calculations. This tool does not have a preview of the parsed document, so the users would know and expect that their data might be in let's say a range, like "B5:C9". But with the current limitation, such a range will return different values if the table has categories, or is a pivot table, or just a simple table with custom sorting applied.

ibrahimabdo avatar Jun 06 '25 15:06 ibrahimabdo