Closed bradleypeabody closed 3 months ago
This is definitely a bug - it's causing the output files to be considered corrupt when opening in Excel too. (See #788 )
@tealeg Although I haven't thoroughly tested it, it seems like just documenting that column indexes start from 1 (not 0) would solve it, no? That would be easy and would reflect the functionality as it exists right now.
Yup. Fixed in this commit
Using the latest v3 as of this writing, when trying to set column widths following the example from here: https://github.com/tealeg/xlsx/blob/master/tutorial/tutorial.adoc#working-with-columns
The example reads as follows:
I tried this using
xlsx.NewColForRange(0,0)
and when I open the resulting file with LibreOffice I get an error sayingThe data could not be loaded completely because the maximum number of columns per sheet was exceeded.
and the column width is not applied.After unzipping and looking at the raw output and comparing a working sheet saved by LibreOffice vs what the above was outputting, it seems like column index 0 was put literally into the XML, when it looks like the first column is supposed to be numbered 1 (based on dissecting a working file created with LibreOffice manually). Changing the code to
xlsx.NewColForRange(1,1)
produces the desired result.I suggest updating the example and mentioning both in the tutorial and in the relevant function comments (e.g. for NewColForRange(), Col() and any others) that column indexes start from 1 (i.e. col A=1, B=2, etc; not zero as is the case with rows).