diff options
| author | 2019-01-14 01:40:56 -0500 | |
|---|---|---|
| committer | 2019-01-14 01:40:56 -0500 | |
| commit | dddfa903d2b856146f05ffb4415c31d6127bb5bf (patch) | |
| tree | e38c2aca92b54f06ccd0185f48dc47e3e1b3d77e /README.md | |
| parent | 8280a21a23d44aa90177e2bc041d0b8dc8556f4b (diff) | |
New upstream version 2.8.0upstream/2.8.0
Diffstat (limited to 'README.md')
| -rw-r--r-- | README.md | 37 |
1 files changed, 25 insertions, 12 deletions
@@ -1,6 +1,6 @@ # Roo -[](https://travis-ci.org/roo-rb/roo) [](https://codeclimate.com/github/roo-rb/roo) [](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) @@ -89,13 +89,13 @@ sheet.last_column You can access the top-left cell in the following ways ```ruby -s.cell(1,1) -s.cell('A',1) -s.cell(1,'A') -s.a1 +sheet.cell(1,1) +sheet.cell('A',1) +sheet.cell(1,'A') +sheet.a1 # Access the second sheet's top-left cell. -s.cell(1,'A',s.sheets[1]) +sheet.cell(1,'A',sheet.sheets[1]) ``` #### Querying a spreadsheet @@ -117,6 +117,12 @@ sheet.parse(id: /UPC|SKU/, qty: /ATS*\sATP\s*QTY\z/) # => [{:id => 727880013358, :qty => 12}, ...] ``` +Use the ``:headers`` option to include the header row in the parsed content. + +```ruby +sheet.parse(headers: true) +``` + Use the ``:header_search`` option to locate the header row and assign the header names. ```ruby @@ -129,6 +135,16 @@ Use the ``:clean`` option to strip out control characters and surrounding white sheet.parse(clean: true) ``` +#### Options + +When opening the file you can add a hash of options. + +##### expand_merged_ranges +If you open a document with merged cells and do not want to end up with nil values for the rows after the first one. +```ruby +xlsx = Roo::Excelx.new('./roo_error.xlsx', {:expand_merged_ranges => true}) +``` + ### Exporting spreadsheets Roo has the ability to export sheets using the following formats. It will only export the ``default_sheet``. @@ -230,7 +246,7 @@ ods.formula('A', 2) ```ruby # Load a CSV file -s = Roo::CSV.new("mycsv.csv") +csv = Roo::CSV.new("mycsv.csv") ``` Because Roo uses the [standard CSV library](), you can use options available to that library to parse csv files. You can pass options using the ``csv_options`` key. @@ -240,10 +256,10 @@ For instance, you can load tab-delimited files (``.tsv``), and you can use a par ```ruby # Load a tab-delimited csv -s = Roo::CSV.new("mytsv.tsv", csv_options: {col_sep: "\t"}) +csv = Roo::CSV.new("mytsv.tsv", csv_options: {col_sep: "\t"}) # Load a csv with an explicit encoding -s = Roo::CSV.new("mycsv.csv", csv_options: {encoding: Encoding::ISO_8859_1}) +csv = Roo::CSV.new("mycsv.csv", csv_options: {encoding: Encoding::ISO_8859_1}) ``` ## Upgrading from Roo 1.13.x @@ -272,9 +288,6 @@ You can run the tests/examples with Rspec like reporters by running Roo also has a few tests that take a long time (5+ seconds). To run these, use `LONG_RUN=true bundle exec rake` -When testing using Ruby 2.0 or 2.1, use this command: -`BUNDLE_GEMFILE=Gemfile_ruby2 bundle exec rake` - ### Issues If you find an issue, please create a gist and refer to it in an issue ([sample gist](https://gist.github.com/stevendaniels/98a05849036e99bb8b3c)). Here are some instructions for creating such a gist. |
