diff --git a/README.md b/README.md index 2d09cbd4..622b36b4 100644 --- a/README.md +++ b/README.md @@ -22,22 +22,37 @@ gem "roo", "~> 2.10.0" ``` ## Usage -Opening a spreadsheet +### Opening a spreadsheet +You can use the `Roo::Spreadsheet` class so `roo` automatically detects which [parser class](https://github.com/roo-rb/roo/blob/master/lib/roo.rb#L17) to use for you. ```ruby require 'roo' -xlsx = Roo::Spreadsheet.open('./new_prices.xlsx') -xlsx = Roo::Excelx.new("./new_prices.xlsx") +file_name = './new_prices.xlsx' +xlsx = Roo::Spreadsheet.open(file_name) +xlsx.info +# => Returns basic info about the spreadsheet file +``` -# Use the extension option if the extension is ambiguous. -xlsx = Roo::Spreadsheet.open('./rails_temp_upload', extension: :xlsx) +``Roo::Spreadsheet.open`` can accept both string paths and ``File`` instances. Also, you can provide the extension of the file as an option: + +```ruby +require 'roo' +file_name = './rails_temp_upload' +xlsx = Roo::Spreadsheet.open(file_name, extension: :xlsx) xlsx.info # => Returns basic info about the spreadsheet file ``` -``Roo::Spreadsheet.open`` can accept both paths and ``File`` instances. +On the other hand, if you know what the file extension is, you can use the specific parser class instead: +```ruby +require 'roo' + +xlsx = Roo::Excelx.new("./new_prices.xlsx") +xlsx.info +# => Returns basic info about the spreadsheet file +``` ### Working with sheets