Note that there are some explanatory texts on larger screens.

plurals
  1. POexcel import is not working with spreadsheet gem
    primarykey
    data
    text
    <p>I am using Spreadsheet gem to import excel data to database. my view is:-</p> <pre><code>&lt;% form_for :dump, :url=&gt;{:action=&gt;"excel_import"}, :html =&gt; { :multipart =&gt; true } do |f| -%&gt; Select an Excel File : &lt;%= f.file_field :excel_file -%&gt; &lt;%= submit_tag 'Submit' -%&gt; &lt;% end -%&gt; </code></pre> <p>and my controller is :-</p> <pre><code>require 'spreadsheet' def excel_import Spreadsheet.client_encoding = 'UTF-8' book = Spreadsheet.open params[:dump][:excel_file] sheet1 = book.worksheet 0 sheet1.each do |row| TimeSheet.new(:ac_no =&gt; row[0]).save end end </code></pre> <p>Parameters:-</p> <pre><code> {"utf8"=&gt;"✓", "authenticity_token"=&gt;"vhyy1pzYJpM9hCdgP5AiFC1Pv0UtbpLSzStZDWiZzs8=", "dump"=&gt;{"excel_file"=&gt;#&lt;ActionDispatch::Http::UploadedFile:0x9a8f5f8 @original_filename="SwipeData_DeliveryTeam_Sep12.xls", @content_type="application/vnd.ms-excel", @headers="Content-Disposition: form-data; name=\"dump[excel_file]\"; filename=\"SwipeData_DeliveryTeam_Sep12.xls\"\r\nContent-Type: application/vnd.ms-excel\r\n", @tempfile=#&lt;File:/tmp/RackMultipart20121025-4534-n7pw14&gt;&gt;}, "commit"=&gt;"Submit"} </code></pre> <p>when i am trying to upload excel file and click on submit button, I am getting error:-</p> <pre><code> can't convert ActionDispatch::Http::UploadedFile into String </code></pre> <p>I have taken the reference from <a href="http://openrails.blogspot.in/2011/06/xls-import-using-spreadsheet.html" rel="nofollow">blog</a></p> <p>can anyone please tell me what is going wrong in this code.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload