zdavatz / spreadsheet

The Ruby Spreadsheet by ywesee GmbH
http://spreadsheet.ch
GNU General Public License v3.0
1.13k stars 240 forks source link

Create an excel file with more than 256 columns #265

Open sokmesakhiev opened 2 years ago

sokmesakhiev commented 2 years ago

I am having trouble creating an excel file with 355 columns. I opened it via Microsoft excel and there is a message warning me that the file is corrupt but it allowed me to view it. Inside the file, there are only 256 columns created and the other 95 columns are missing.

Screen Shot 2022-04-01 at 1 56 35 PM Screen Shot 2022-04-01 at 1 56 48 PM Screen Shot 2022-04-01 at 1 57 06 PM Screen Shot 2022-04-01 at 1 57 17 PM
zdavatz commented 2 years ago
  1. Which office version?
  2. Which OS?
  3. Download Libreoffice, open the file with Libreoffice, save the file and try again.
  4. Which software created the original XLS file?
reviewher commented 2 years ago

XLS file format has a hard limit of 256 columns (A = 0 ... IV = 255) but the library does not enforce the constraint. In light of common row limit errors like https://www.bbc.co.uk/news/technology-54423988 , the best fix is to truncate with warning or error when trying to write beyond the limits.

The file can still be repaired because the col field of the Cell structure is 2 bytes wide. The file can technically support up to XFD (column 65535) but the Excel parser will fail.

sokmesakhiev commented 2 years ago
  1. Which office version?
  2. Which OS?
  3. Download Libreoffice, open the file with Libreoffice, save the file and try again.
  4. Which software created the original XLS file?

I use Microsoft Office on latest Mac OS. I don't try with LibreOffice yet but I use gem to create xls file.

sokmesakhiev commented 2 years ago

XLS file format has a hard limit of 256 columns (A = 0 ... IV = 255) but the library does not enforce the constraint. In light of common row limit errors like https://www.bbc.co.uk/news/technology-54423988 , the best fix is to truncate with warning or error when trying to write beyond the limits.

The file can still be repaired because the col field of the Cell structure is 2 bytes wide. The file can technically support up to XFD (column 65535) but the Excel parser will fail.

Yes, I feel it is the limitation of XLS.

zdavatz commented 2 years ago

I use Microsoft Office on latest Mac OS. I don't try with LibreOffice yet but I use gem to create xls file.

Please give it a try wit LibreOffice.