question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Worksheet.Set_Column - Grouping Column Issue

See original GitHub issue

Hi,

I am using XlsxWriter to add grouping to columns dynamically through iterations, but it appears to do incorrectly group columns.

I am using Python version 3.6.3 and XlsxWriter 1.1.5

Here is some code that demonstrates the problem:


import xlsxwriter

        for i in range(11, ColEnd):
            if ColNum == 6:
                ColNum = 1
            if ColNum == 1:
                secondCol = i +4
                SummaryTab.set_column('{}:{}'.format(xlsxwriter.utility.xl_col_to_name(i),
                                               xlsxwriter.utility.xl_col_to_name(secondCol)), 15, None, {'level': 1})
            ColNum += 1

SummaryReport.close()

Currently using ‘{}:{}’ to insert the column letter dynamically as it iterates through the numbers, however it does not take the second argument correctly. It will only group the first column rather than the 4 column range.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
jmcnamaracommented, Mar 26, 2019

Can you submit a small, complete example that demonstrates the issue. A segment of the code isn’t helpful.

Note also, set_column() can take a numeric range (for example 0, 2 instead of ‘A:C’). That isn’t related to your issue but it is more efficient. See the set_column() docs: https://xlsxwriter.readthedocs.io/worksheet.html#worksheet-set-column

0reactions
jmcnamaracommented, Mar 26, 2019

I removed a bunch of code and change some things but the below works.

Good. Thanks for letting me know. I’ll close the issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Outline (group) data in a worksheet - Microsoft Support
Use an outline to group data and quickly display summary rows or columns, or to reveal the detail data for each group.
Read more >
How to group columns in Excel - Ablebits
To group columns in Excel, perform these steps: Select the columns you want to group, or at least one cell in each column....
Read more >
How to Enable Grouping of Columns in Excel? - eduCBA
To Ungroup Columns in Excel​​ On the Data tab, in the Outline group, click on Ungroup command. Click on the columns and then...
Read more >
Can't Add Grouping in Excel? Buttons Greyed-Out? Easy Fix!
The problem · Solution 1: Only select one worksheet to group rows or columns · Solution 2: You are editing a cell –...
Read more >
Excel Problem: Group and Ungroup not working in Excel
... how to get the rid of excel problem when Group /Ungroup (Outlin... ... Group /Ungroup (Outline) is not working on a particular...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found