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

Add a basic example of opening an xls 2003 spreadsheet to readme #8

Open
equivalentideas opened this issue Jun 13, 2015 · 3 comments
Open
Assignees

Comments

@equivalentideas
Copy link

Thanks for the gem. I'm trying to open a Microsoft Excel 97-2004 Worksheet with:

book = Roo::Spreadsheet.open 'AusTender-Contract-Notice-Export_20150613_183324.xls', extension: :xls

and getting the error Ole::Storage::FormatError: OLE2 signature is invalid.

I'm not confident I'm using this correctly, a simple example of opening a file would make a very useful addition to the readme. Anything would be better than nothing ;)

Thanks again

@JackWells
Copy link

After installing the gem, does one just add "require 'roo-xls" (along with require "roo") to your class, and then use roo on the xls file as you would with other speadsheet files, which are supported by roo alone? That's just a guess, so even a few lines of 'how to use it' would be very helpful.

@JoseMPena
Copy link

After installing the gem, does one just add "require 'roo-xls" (along with require "roo") to your class, and then use roo on the xls file as you would with other speadsheet files, which are supported by roo alone? That's just a guess, so even a few lines of 'how to use it' would be very helpful.

I see the issue is closed. is this the correct usage, then?

@tgturner
Copy link
Contributor

tgturner commented Sep 26, 2018

@JoseMPena I apologize, I closed this because it was old. The correct usage is like this:

begin
  require "bundler/inline"
rescue LoadError => e
  $stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
  raise e
end

gemfile(true) do
  source "https://rubygems.org"

  git_source(:github) { |repo| "https://github.com/#{repo}.git" }

  gem "roo-xls"
  gem "minitest"
end

require "roo-xls"
require "minitest/autorun"

class BugTest < Minitest::Test
  def test_stuff
    sheet = Roo::Excel.new('/Users/gturner/downloads/table.xls')
    puts sheet.row(1)
  end
end

You only need the roo-xls gem as it will require the roo gem. You need to use the Roo::Excel class to operate on excel spreadsheets. I'll reopen this issue to add some example to the docs.

@tgturner tgturner reopened this Sep 26, 2018
@tgturner tgturner self-assigned this Sep 26, 2018
claasz added a commit to claasz/roo-xls that referenced this issue Jan 14, 2021
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