Free Ultra-Fast Ruby Writer and Reader for Excel XLSX
A Blazing-Fast Open Source Ruby Library allows Software Developers to Create, Read and Manipulate Excel XLSX Files. Apply Excel Cell, Row and Column Formatting, Merging & Splitting.
What is Fast_Excel?
Is your Ruby application slowed down by inefficient Excel generation? Meet Fast_Excel, the Ultra-Fast Excel Writer designed for fast Excel file creation without the memory overload. This powerful open source Ruby spreadsheet API acts as a Ruby FFI binding for the optimized libxlsxwriter C library, delivering the speed of C with a clean Ruby interface. As a high-performance free Ruby Excel Library, it enables you to seamlessly create Excel XLSX files and manage XLSX spreadsheet data while maintaining a minimal memory footprint—perfect for generating large reports on the fly.
Fast_Excel is a feature-rich solution that empowers developers to create Excel XLSX spreadsheet documents and create CSV files with ease. Beyond speed, it provides extensive control to apply cell, row and column formatting, add formulas, and build multi-sheet workbooks. Its efficient architecture ensures operations are significantly quicker than pure Ruby alternatives, keeping server resources in check. Whether you need to create ODS spreadsheet outputs or handle complex Excel features, Fast_Excel combines raw performance with an intuitive, Ruby-friendly API for all your spreadsheet export needs.
Getting Started with Fast_Excel
The recommend way to install Fast_Excel library is by using RubyGems. Please use the following command for smooth installation.
Install rubyX via RubyGems
$ gem install fast_excel Writing a Simple Spreadsheet via Ruby API
The open source Fast_Excel library makes it easy for software programmers to create new Excel XLSX files very efficiently and with low memory overhead inside their own Ruby applications. The primary use case is generating a simple spreadsheet from an array of data. It supports adding new worksheets, renaming existing worksheets, inserting text and image and so on. Here is a simple example that shows how to create a simple XLSX spreadsheet inside Ruby Apps.
How to Create a Simple Spreadsheet via Ruby Library?
require 'fast_excel'
# Create a new workbook
workbook = FastExcel.open("constant_memory.xlsx", constant_memory: true)
# Add a worksheet
worksheet = workbook.add_worksheet("User Report")
# Add data rows. The write_row method accepts an array of values.
worksheet.write_row(0, ["ID", "Name", "Email"]) # Header row (row index 0)
users = User.limit(10000)
users.each_with_index do |user, index|
# Write each row, starting from row 1
worksheet.write_row(index + 1, [user.id, user.name, user.email])
end
# Don't forget to close the workbook to save the file!
workbook.close
Advanced Cell Formatting via Ruby
The Fast_Excel library makes has provided complete support for a rich set of formatting options to make your spreadsheets look professional and readable. You can define font size, font family, color (including RGB), styles like bold/italic, underline variants, strikeout, text wrapping, rotation, indent, borders (thin, double, etc.), alignment (horizontal, vertical), number formats, etc. Here is a very useful example that shows how software developers can apply different types of formatting to cells, rows and columns of Excel worksheets inside ruby apps.
How to Apply Advanced Formatting to Excel Worksheets via Ruby API?
require 'fast_excel'
workbook = Fast_Excel.open("formatted_report.xlsx")
# Create a bold format
bold = workbook.bold_format
# Create a custom number format
currency_format = workbook.number_format("$#,##0.00")
worksheet = workbook.add_worksheet("Sales Report")
# Set column widths and formats
worksheet.set_column(0, 0, 20)
worksheet.set_column(1, 1, 15, currency_format)
# Write a header row with bold formatting
worksheet.append_row(["Product", "Revenue"], bold)
# Write data rows
worksheet.append_row(["Product A", 15000])
worksheet.append_row(["Product B", 25000])
workbook.close
Column and Row Manipulation via Ruby API
The Fast_Excel library allows software developers to work with rows and columns of an Excel spreadsheets inside Ruby apps. It has provided full control over the dimensions of your columns and rows. You can set specific widths and heights, and Fast_Excel even supports auto-width for string values. The following example demonstrates how to work with rows and columns of an Excel spreadsheet using Ruby commands.
How to Set the Width and Height of Spreadsheet Row or Column via Ruby?
require 'fast_excel'
workbook = Fast_Excel.open("column_width.xlsx")
worksheet = workbook.add_worksheet
# Set the width of the first column to 30
worksheet.set_column(0, 0, 30)
# Set the height of the first row to 40
worksheet.set_row(0, 40)
worksheet.append_row(["This is a long string that needs more space"])
workbook.close
Better Speed and Performance
The open source Fast_Excel library has very high speed and significantly outperforms pure-Ruby gems, especially with large datasets. As FastExcel uses libxlsxwriter (C library), operations are much faster than pure Ruby libraries. Benchmarks show it outperforms others such as Axlsx by several times. Writing 1,000 rows – Fast_Excel is ~3–4× faster than Axlsx; for large data (20,000 rows), it’s still significantly faster.