From c62f8376a13e7a4f493167aba1c66a9201fc59c6 Mon Sep 17 00:00:00 2001 From: Unit 193 Date: Wed, 26 Nov 2025 19:02:28 -0500 Subject: New upstream version 3.0.0. --- README.md | 48 ++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 40 insertions(+), 8 deletions(-) (limited to 'README.md') diff --git a/README.md b/README.md index 021afb4..be3016f 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Roo -[![Build Status](https://img.shields.io/travis/roo-rb/roo.svg?style=flat-square)](https://travis-ci.org/roo-rb/roo) [![Maintainability](https://api.codeclimate.com/v1/badges/be8d7bf34e2aeaf67c62/maintainability)](https://codeclimate.com/github/roo-rb/roo/maintainability) [![Coverage Status](https://img.shields.io/coveralls/roo-rb/roo.svg?style=flat-square)](https://coveralls.io/r/roo-rb/roo) [![Gem Version](https://img.shields.io/gem/v/roo.svg?style=flat-square)](https://rubygems.org/gems/roo) +[![Build Status](https://img.shields.io/github/actions/workflow/status/roo-rb/roo/ruby.yml?style=flat-square)](https://travis-ci.org/roo-rb/roo) [![Maintainability](https://api.codeclimate.com/v1/badges/be8d7bf34e2aeaf67c62/maintainability)](https://codeclimate.com/github/roo-rb/roo/maintainability) [![Coverage Status](https://img.shields.io/coveralls/roo-rb/roo.svg?style=flat-square)](https://coveralls.io/r/roo-rb/roo) [![Gem Version](https://img.shields.io/gem/v/roo.svg?style=flat-square)](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. -- cgit v1.2.3