1

I'm using openpyxl to build a data-entry template to distribute to users. Some of these columns will have the possible values of ("true", "false", "unknown"), so I would like Excel to treat these columns as text instead of Boolean, even if the users only enter the values of "true" or "false" into them. I don't know up front how many rows any particular user will be entering, so looping through the whole sheet with

template_ws.cell(row_number, column_number).number_format = "@"

is not practical because I'd have to do it for all 1048576 potential rows.

If I was doing this in Excel, I'd click on the column letter and then change the format from "General" to "Text". Is there a programmatic way to do this with openpyxl without having to format each individual cell?

sea_nw
  • 23
  • 5
  • 1
    Read [applying-styles](https://openpyxl.readthedocs.io/en/stable/styles.html#applying-styles) – stovfl Oct 25 '19 at 21:47
  • I already have, which is where I got the information on applying the style to each cell. I'd been hoping that I'd either missed something or had misinterpreted what I read. – sea_nw Nov 04 '19 at 16:01
  • There is a `'Normal'` style which should be used for all Cells, where **not** manually is assigned a style, but didn't get it to work. – stovfl Nov 04 '19 at 16:15

0 Answers0