Ruby Spreadsheet Library to Create XLSX, ODS, or CSV Files
Open Source Ruby API to Generate and Handle XLSX, ODS, or CSV Spreadsheets Documents, Generate Multi-sheet Spreadsheets Files, Add Rows & Columns via Ruby Commands.
What is Spreadsheet Architect?
The open source Ruby library Spreadsheet Architect is very useful for the creation and handling of spreadsheet documents using Ruby commands. The library has included support for the creation of XLSX, ODS, or CSV spreadsheets with ease. The library allows spreadsheet creation from ActiveRecord relations, plain Ruby objects, or tabular data.
The Spreadsheet Architect library is very stable and easy to use. It has included several important features related to spreadsheet management, such as creating a new spreadsheet file from the scratch, creating a spreadsheet from custom data, generating the header, inserting rows and columns, applying styles to spreadsheets cells, adding new worksheets, adding new cells, customize cell data and so on.
Using the Spreadsheet Architect library developers can generate multi-sheet spreadsheets document with just a couple of lines of code. All the features related to basic formatting can be easily applied such as bold, italic, underline, text alignment, applying text and cell color, font size, and many more. It has also provided some style aliases that can be easily used inside your applications.
Getting Started with Spreadsheet Architect
The recommended way to install Spreadsheet Architect into your project is by using RubyGems. Please use the following command for an easy installation.
Install Spreadsheet Architect via RubyGems
gem 'spreadsheet_architect'
Generate XLSX and ODS Spreadsheet via Ruby
The open source Ruby library Spreadsheet Architect has provided software developers the capability to generate XLSX and ODS documents with ease. You can easily add new sheets, update existing sheets, rename sheets, apply formatting to a range of cells, and much more. The library also provides support for editing the contents of a sheet with just a couple of lines of code.
How to Generate Multi Sheet XLSX Spreadsheets via Ruby AP?
axlsx_package = SpreadsheetArchitect.to_axlsx_package({headers: headers, data: data})
axlsx_package = SpreadsheetArchitect.to_axlsx_package({headers: headers, data: data}, axlsx_package)
File.open('path/to/multi_sheet_file.xlsx', 'w+b') do |f|
f.write axlsx_package.to_stream.read
end
Combine Multiple Worksheets via Ruby
The free library Spreadsheet Architect enables software programmers to combine multiple worksheets into a single file using Ruby commands. You need to provide the names and complete addresses of the worksheets. After that, it is very easy to join them on another sheet of your choice. Once the process is completed you can easily apply new styles, add new columns or rows, and insert images to it with ease.
Add Images & Styles to Excel Worksheet
The open source Ruby library Spreadsheet Architect gives software programmers the capability to add images inside their spreadsheet with just a couple of lines of Ruby code. You can easily style and customize spreadsheet contents. A developer can adjust its size, replace it with another image, and delete unwanted images with ease.
How to Wrap Text via Ruby API?
$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
require 'axlsx'
p = Axlsx::Package.new
p.workbook do |wb|
wb.styles do |s|
wrap_text = s.add_style :fg_color=> "FFFFFF",
:b => true,
:bg_color => "004586",
:sz => 12,
:border => { :style => :thin, :color => "00" },
:alignment => { :horizontal => :center,
:vertical => :center ,
:wrap_text => true}
wb.add_worksheet(:name => 'wrap text') do |sheet|
sheet.add_row ['Torp, White and Cronin'], :style => wrap_text
# Forcing the column to be a bit narrow so we can see if the text wrap.
sheet.column_info.first.width = 5
end
end
end
p.serialize 'wrap_text.xlsx'