title: Using Roo with Ruby(Rails) to parse Excel
body: <p>I'm trying to allow users to upload a CSV/Excel document, and parse it using Roo (The most suggested one I've seen), but I'm having a bit of issues figuring it out.</p>
  
  <p><strong>Current Script</strong></p>
  
  <pre><code>require 'roo'
  
  xlsx = Roo::Excelx.new("./TestAppXL.xlsx")
  xlsx.each_row_streaming do |row|
    puts row.inspect # Array of Excelx::Cell objects
  end
  </code></pre>
  
  <p>This was the only one I was able to get work - It returns what looks to be JSONB. </p>
  
  <p>What I'm trying to do is a few part process:</p>
  
  <p>A) User Uploads a list of 'cards' to my website.(Trying to allow as many options as possible. CSV, Excel, etc)</p>
  
  <p>B) It instantly returns a list of the headers and asks 'Which header is name, quantity, etc etc?'</p>
  
  <p>C) I parse the data for specifics headers and do 'X'.</p>
  
  <p>B is what I primarily need help with. I'm struggling to figure out Roo exactly. I won't have control over the headers so I can't use numerical column numbers.</p>
  
  <p>(Adding in Rails tag since this will be in a controller in the end, maybe an easier way to do it.)</p>
  
  <p><strong>Updated Script</strong></p>
  
  <p>I've actually made a lot of progress. Still trying to get closer to my original request.</p>
  
  <pre><code>require 'roo'
  require 'roo-xls'
  
  xlsx = Roo::Spreadsheet.open('Demo.xls')
  headers =  xlsx.first_row
  puts xlsx.row(headers)
  puts "Which number header is the Card Name?"
  CardName = gets
  puts xlsx.column(CardName.to_i)
  # =&gt; Returns basic info about the spreadsheet file
  </code></pre>
  
  <p>Need a lot more logic on the gets but currently if I put in '3' it will return all content of Column 'CardName'. Working on iterating over the rows now.</p>
  
  <p><strong>Psuedo working script</strong></p>
  
  <pre><code>require 'roo'
  require 'roo-xls'
  
  xlsx = Roo::Spreadsheet.open('Demo.xls')
  headers =  xlsx.first_row
  puts xlsx.row(headers)
  puts "Which number header is the Card Name?"
  CardName = gets.to_i
  specHeader = xlsx.cell(headers,CardName)
  xlsx.column(CardName).drop(0).each_with_index do |item, index|
      if index == 0
  
      else
          puts item
      end
  end
  </code></pre>
  
  <p>This is actually performing as expected, and I can start feeding the file into a Rake job now. Still working on some of the iteration but this is very close.</p>