Grouping rows

68 views
Skip to first unread message

Eugenijus Januškevičius

unread,
Jan 16, 2025, 3:02:32 AMJan 16
to openpyxl-users
Hi All,

I have strange issue with grouping rows.
sheet.row_dimensions.group(block_start_row, current_row-1, outline_level=2, hidden=False)
print(F"\t\t GROUPING rows {block_start_row}:{current_row-1} @L2")
...
sheet.row_dimensions.group(project_file_start_row, current_row-1, outline_level=1, hidden=False)
print(F"\t\t GROUPING rows {project_file_start_row}:{current_row-1}")

What I see in the output:

GROUPING rows 2826:2840 @L2
...
GROUPING rows 3415:3435 @L2
GROUPING rows 3436:3458 @L2
GROUPING rows 3459:3482 @L2
GROUPING rows 2826:3482

The boundaries do not intersect, but just the highest level is grouped in the XLSX file. Do I miss something? There is moving block and the length of the first and the second grouping is not known in advance. I could collect row ranges and crealte lelev 2 grouping after L1, if it would help.

Charlie Clark

unread,
Jan 16, 2025, 6:41:43 AMJan 16
to openpyxl-users

On 16 Jan 2025, at 9:02, Eugenijus Januškevičius wrote:

The boundaries do not intersect, but just the highest level is grouped in
the XLSX file. Do I miss something? There is moving block and the length of
the first and the second grouping is not known in advance. I could collect
row ranges and crealte lelev 2 grouping after L1, if it would help.

I hate everything to do with outlining/grouping in OOXML: the two are needlessly conflated and also implemented differently for rows and columns and the documentation is not very helpful.

Really, the best thing to do is to create a sample worksheet in Excel, open the source XML in a suitable editor and then work out what you need to do in Openpyxl. From memory, because I was trying something similar last year, there are problems with adjacent groups of rows.

Charlie

--
Charlie Clark
Managing Director
Clark Consulting & Research
German Office
Sengelsweg 34
Düsseldorf
D- 40489
Tel: +49-203-3925-0390
Mobile: +49-178-782-6226

Eugenijus Januškevičius

unread,
Jan 16, 2025, 7:17:51 AMJan 16
to openpyxl-users
Well, this roadmap is almost impossible. I would like to create every instance from scratch.
Current assignment is: take the YAML file, make it DOCX/ ODF, XLSX/ODS or IDS (the XML flavour, used for IFC model checks).
The XLSX file currently contains ca 3800 rows in c.a. 15 sections and a huge number of subsections. For now, I will leave section grouping and maybe will implement subsection grouping in beta stage of the software. Anyway, grouping is nice to have, but not a must.
Reply all
Reply to author
Forward
0 new messages