Fold columns (column_dimensions.group) does not appear to support multiple levels

Issue #1059 invalid
Daniel OHara
created an issue

This code attempts to define two levels of column folding:

import openpyxl
wb = openpyxl.Workbook()
wb.active.column_dimensions.group('A', 'D')
wb.active.column_dimensions.group('B', 'C')
wb.save('openpyxlGroupTest.xlsx')

Worksheets xml contains:

<cols>
    <col max="4" min="1" outlineLevel="1" />
    <col max="3" min="2" outlineLevel="1" />
</cols>

When I do the same thing in Excel I get:

<cols>
    <col min="1" max="1" width="8.88671875" customWidth="1" outlineLevel="1"/>
    <col min="2" max="3" width="8.88671875" customWidth="1" outlineLevel="2"/>
    <col min="4" max="4" width="8.88671875" customWidth="1" outlineLevel="1"/>
</cols>

Comments (4)

  1. Daniel OHara reporter

    In case any one stumbles over this the code looks like:

    import openpyxl
    wb = openpyxl.Workbook()
    wb.active.column_dimensions.group('A', 'A')
    wb.active.column_dimensions.group('B', 'C', outline_level=2)
    wb.active.column_dimensions.group('D', 'D')
    wb.save('openpyxlGroupTest.xlsx')
    
  2. Log in to comment