Read more

Excel files can't hold more than 65535 rows per worksheet

Arne Hartherz
November 18, 2011Software engineer at makandra GmbH

"Classic" Excel (XLS) has a magic limit of 65535 rows per worksheet. This was fixed in XLSX but the version used by the Spreadsheet gem Show archive.org snapshot can only write XLS files.

Illustration online protection

Rails Long Term Support

Rails LTS provides security patches for old versions of Ruby on Rails (2.3, 3.2, 4.2 and 5.2)

  • Prevents you from data breaches and liability risks
  • Upgrade at your own pace
  • Works with modern Rubies
Read more Show archive.org snapshot

If you want to write more data, consider hacking around it using in_groups_of and writing multiple column sets of your data (i.e. split 1 block of 3 columns and 100000 rows into 4 blocks of 3 (12 in total) columns and 25000 rows).

You can do this until you reach the other limit of 256 columns. After that, open up a new workbook or consider a better file type.

As an alternative, you could switch to axlsx, which supports writing XLSX files -- and does that really fast, too.

Posted by Arne Hartherz to makandra dev (2011-11-18 16:45)