minimalist_ods
is a minimalist gem for generating ODS (Open Document Spreadsheet) files in Ruby. This gem is designed specifically for exporting data to ODS format.
Add this line to your Gemfile:
gem 'minimalist_ods'
And then execute:
bundle install
Or install it yourself as:
gem install minimalist_ods
To create an ODS file, first initialize an ODS
object with the file name and the creator's name:
require 'minimalist_ods'
# by default, creator metadata will be minimalist-ods, you can set it as the second argument in your constructor
ods = MinimalistODS.new('example.ods', 'Creator')
To add a table, use the open_table
method with the table name and the number of columns:
ods.open_table('Sheet1', 3)
To add a row, use the add_row
method with an array of values:
ods.add_row(['Name', 'Age', 'City'])
ods.add_row(['Alice', 30, 'New York'])
ods.add_row(['Bob', 25, 'San Francisco'])
Once you have finished adding rows, close the table using:
ods.close_table
Finally, close the file to save the changes:
ods.close_file
require 'minimalist_ods'
ods = MinimalistODS.new('example.ods', 'Your Name')
ods.open_table('Sheet1', 3)
ods.add_row(['Name', 'Age', 'City'])
ods.add_row(['Alice', 30, 'New York'])
ods.add_row(['Bob', 25, 'San Francisco'])
ods.close_table
ods.close_file
Contributions are welcome. Please open an issue or a pull request on the GitHub repository.
This gem is available as open source under the terms of the MIT License.