Skip to content

Instantly share code, notes, and snippets.

@BiggerNoise
Created January 25, 2013 18:38
Show Gist options
  • Save BiggerNoise/4636781 to your computer and use it in GitHub Desktop.
Save BiggerNoise/4636781 to your computer and use it in GitHub Desktop.
Shows using the spreadsheet gem to read a file that is flawed. Worksheets and dimensions are correct, but cell data cannot be read. File that causes the issue can be found at: http://dl.dropbox.com/u/83477489/sample.xls
#!/usr/bin/env ruby
wb = Spreadsheet.open('sample.xls')
puts "Opened Spreadsheet, #{wb.sheet_count} sheets encountered"
(0..wb.sheet_count-1).each do |sheet_number|
ws = wb.worksheet(sheet_number)
puts "\tWorksheet #{ws.name} has #{ws.row_count} rows and #{ws.column_count} columns}; and Dimensions: #{ws.dimensions}"
end
puts "Opened Spreadsheet, #{wb.sheet_count} sheets encountered"
ws = wb.worksheet(0)
puts "\tWorksheet '#{ws.name}' has #{ws.row_count} rows and #{ws.column_count} columns}; and Dimensions: #{ws.dimensions}"
row_index = 5
row = ws.row row_index
puts "\tWorksheet '#{ws.name}' row #{row_index}: #{row.to_s}"
puts "\tWorksheet '#{ws.name}' cell(#{row_index}, 0): #{ws.cell(row_index, 0)}"
@BiggerNoise
Copy link
Author

Yes, that's the same thing that I have been getting. You can read the sheets and their titles, but you cannot see any of the data.

So, no, this is still not working for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment