Software and Technology Ramblings

January 14, 2008

Ruby Spreadsheet-Excel gem – 255 character limit

Filed under: Rails — Doug Hays @ 1:28 pm

A client of mine let me know today that the Excel spreadsheets I was generating for them had data truncated at 255 characters. I didn’t find anything on the web that gave a reason or offered a fix so I decided to dig into the code myself. I am using the Ruby Spreadsheet-Excel gem.

Sure enough, on line 289, of workbook.rb (v0.3.5.1), there was this:

      # Truncate strings over 255 characters
      if strlen > StrMax
         str    = str[0..StrMax-1]
         length = 0x0008 + StrMax
         strlen = StrMax

No idea why this was done and I wasn’t going to waste anytime considering the downsides of not truncating, so I commented this block out and it works fine.

Maybe it has something to do with an older version of Excel? Who knows.


No comments yet.

RSS feed for comments on this post. TrackBack URL

Leave a comment

You must be logged in to post a comment.

Powered by WordPress