Reputation: 11
I am looking for a Ruby Gem which can read an xlsx template and update certain rows in the file and save it as a new file. Is there any Gem that does this? I found a gem called SpreadsheetX which creates Excel files based on a template. But I don't find a documentation for the same.
Upvotes: 1
Views: 857
Reputation: 880
The spreadsheetx
gem that you have already identified does indeed appear to suit your needs—your problem instead seems to be that it doesn't have usage documentation?
In that case, take a look the specs as they illustrate how to use the gem: https://github.com/craigulliott/spreadsheetx/blob/master/spec/spreadsheetx_spec.rb
Example:
empty_xlsx_file = "#{File.dirname(__FILE__)}/../templates/spec.xlsx"
workbook = SpreadsheetX.open(empty_xlsx_file)
workbook.worksheets.last.update_cell(9, 9, Time.now)
workbook.worksheets.last.update_cell(1, 4, 'A string')
workbook.worksheets.last.update_cell(9, 10, 'A string')
workbook.worksheets.last.update_cell(9, 11, 10.3)
workbook.worksheets.last.update_cell(9, 12, 53)
workbook.worksheets.last.update_cell(9, 13, nil)
new_xlsx_file = "#{File.dirname(__FILE__)}/../templates/spec_various_content.xlsx"
workbook.save(new_xlsx_file)
Upvotes: 1
Reputation: 3154
You can use write_xlsx Gem. Its a nice gem and simple to implement.
Upvotes: 0