Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

is not an Excel file #67

Closed
jtmkrueger opened this issue Sep 9, 2013 · 5 comments
Closed

is not an Excel file #67

jtmkrueger opened this issue Sep 9, 2013 · 5 comments

Comments

@jtmkrueger
Copy link

I think there's something very simple that I don't see going on here that's wrong. Heres My jquery code that's uploading the file:

import: function (e) {
    e.preventDefault();

    var formData = new FormData();
    jQuery.each($('#import_excel_file')[0].files, function(i, file) {
      formData.append('import_file', file, 'xls');
    });
    formData.append('fuel_type_id', $('#import_fuel_type').val());

    this.shipOff(formData);
  },

  shipOff: function (formData) {
    $.ajax({
      type: 'POST',
      url: App.Options.rootUrl + "/stations/stations/excel_import",
      data: formData,
      cache: false,
      contentType: false,
      processData: false,
      success: function (data) {
        console.log('successful upload', data);
      }
    });
  }

Then in the controller, where I call import = Excel.new(xls_file.tempfile.to_path.to_s), I get an error like TypeError (/var/folders/rd/58f3hjw10lv09q_8hsl0l7zn1mn1rf/T/RackMultipart20130909-36782-r1bv5n is not an Excel file)

What am I missing here?

@jtmkrueger
Copy link
Author

Looks like this works:

tmp = params['import_file'].tempfile
tmp_file = File.join("public", params['import_file'].original_filename)
FileUtils.cp tmp.path, tmp_file

then I rm the temp file with FileUtils

if there's an easier way, let me know!

@Empact
Copy link
Contributor

Empact commented Sep 11, 2013

Roo currently uses the extension of the path to check the type of the file. You can ignore type check errors by passing file_warning: :ignore to Excel:

Excel.new(xls_file.tempfile.to_path.to_s, file_warning: :ignore)

@jtmkrueger
Copy link
Author

nice, Thx!

@mulaiko
Copy link

mulaiko commented Jun 23, 2015

I did what's recommened above for a .xls file (using roo-xls) and it worked. but now im running into this:
"OLE2 signature is invalid" any pointers? @jtmkrueger @Empact

@stevendaniels
Copy link
Contributor

@mulaiko

From what I can tell this is probably caused by a file that isn't actually an xls file (e.g. Tab-delimited). If you can, use the "Save As" option in Excel to save it as an xls file.

Sources:
http://stackoverflow.com/questions/17990116/roo-spreadsheet-uploading-ole2-signature-is-invalid
http://atomicules.co.uk/2009/07/17/roo-and-ole2-signature-is-invalid.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants