Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ole::Storage::FormatError: OLE2 signature is invalid

I want to read an Excel File in my Rails Application.

This is how I open my Excel file and read it.

doc = Spreadsheet.open('./try.xls', "r")
sheet = doc.worksheet 0
sheet.each do |row|
array_rows << row.to_a
end

I have it as a rake task.When I try to Read this file it throws an error.

Ole::Storage::FormatError: OLE2 signature is invalid

What is happening? what should I do?

like image 850
Suganya Avatar asked Aug 26 '14 05:08

Suganya


2 Answers

On Mac I had to save it as Excel 97-2004(.xls) to get it to work

like image 147
Stephen O'Reilly Avatar answered Sep 20 '22 09:09

Stephen O'Reilly


The .xls file must be saved in EXCEL 2003 format. So File-->Save As from All Formats dropdown select the Excel year 2003

This solved my problem

like image 21
Suganya Avatar answered Sep 21 '22 09:09

Suganya