diff options
| author | 2025-11-26 19:02:28 -0500 | |
|---|---|---|
| committer | 2025-11-26 19:02:28 -0500 | |
| commit | c62f8376a13e7a4f493167aba1c66a9201fc59c6 (patch) | |
| tree | d58492f972be02c406d26620004e1ffe2086fbc7 /README.md | |
| parent | ae103e148eb3c15606b816505492d870ef062ad3 (diff) | |
New upstream version 3.0.0.upstream/3.0.0upstream
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 48 |
1 files changed, 40 insertions, 8 deletions
@@ -1,6 +1,6 @@ # Roo -[](https://travis-ci.org/roo-rb/roo) [](https://codeclimate.com/github/roo-rb/roo/maintainability) [](https://coveralls.io/r/roo-rb/roo) [](https://rubygems.org/gems/roo) +[](https://travis-ci.org/roo-rb/roo) [](https://codeclimate.com/github/roo-rb/roo/maintainability) [](https://coveralls.io/r/roo-rb/roo) [](https://rubygems.org/gems/roo) Roo implements read access for all common spreadsheet types. It can handle: * Excel 2007 - 2013 formats (xlsx, xlsm) @@ -9,6 +9,11 @@ Roo implements read access for all common spreadsheet types. It can handle: * Excel 97, Excel 2002 XML, and Excel 2003 XML formats when using the [roo-xls](https://github.com/roo-rb/roo-xls) gem (xls, xml) * Google spreadsheets with read/write access when using [roo-google](https://github.com/roo-rb/roo-google) +## Important note about next major release + +There a plan to make a new major release which will have better support for Ruby 3.x +Please leave your comments there - https://github.com/roo-rb/roo/issues/630 + ## Installation Install as a gem @@ -18,26 +23,41 @@ Install as a gem Or add it to your Gemfile ```ruby -gem "roo", "~> 2.9.0" +gem "roo", "~> 3.0.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 @@ -156,6 +176,18 @@ sheet.to_xml sheet.to_yaml ``` +Specify the file as default argument for `#to_csv`: + +```ruby +sheet.to_csv(File.new("/dev/null")) +``` + +specify the custom separator: + +```ruby +sheet.to_csv(separator: ":") # "," using by default +``` + ### Excel (xlsx and xlsm) Support Stream rows from an Excelx spreadsheet. |
