https://github.com/gekola/xlsxwriter-rb
ruby bindings to libxlsxwriter
https://github.com/gekola/xlsxwriter-rb
libxlsxwriter ruby xlsx
Last synced: 12 months ago
JSON representation
ruby bindings to libxlsxwriter
- Host: GitHub
- URL: https://github.com/gekola/xlsxwriter-rb
- Owner: gekola
- License: other
- Created: 2017-01-02T23:03:24.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2025-07-07T15:36:21.000Z (about 1 year ago)
- Last Synced: 2025-07-07T16:27:25.006Z (about 1 year ago)
- Topics: libxlsxwriter, ruby, xlsx
- Language: C
- Size: 157 KB
- Stars: 9
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# XlsxWriter
[](https://travis-ci.com/gekola/xlsxwriter-rb)
[](https://badge.fury.io/rb/xlsxwriter)
## Description
Ruby binding to jmcnamara's [libxlswriter](https://github.com/jmcnamara/libxlsxwriter).
[Documentation link](http://www.rubydoc.info/gems/xlsxwriter/XlsxWriter).
### Usage
The following code snippet creates file `test.xlsx` in current directory with a header and one thousand row with random data.
```ruby
require 'xlsxwriter'
XlsxWriter::Workbook.new('test.xlsx') do |wb|
wb.add_format(:numf, num_format_index: 4) # Excel standard fixed point format (two numbers after point)
wb.add_format(:header, bg_color: 0XCCCCCC, bold: true, bottom: XlsxWriter::Format::BORDER_THIN)
wb.add_worksheet('Worksheet 1') do |ws|
ws.add_row(['Number', 'String'], style: :header)
1_000.times do |i|
ws.add_row([rand * 10_000, 'test string %0d' % (rand * 1000)], style: [:numf])
end
end
end
```
### Motivation
This gem has been written for generating large xlsx files (millions of rows). Pure ruby xlsx libraries do not perform very well in such use cases, consuming lots of memory for intermediate ruby objects and being generally slower (see the benchmark result below, benchmark code is located under `bench/simple_100k_rows.rb`).
Rehearsal ----------------------------------------------
xlsxwriter 0.601120 0.015773 0.616893 ( 0.573616)
axlsx 18.731412 2.845668 21.577080 ( 17.039327)
------------------------------------ total: 22.193973sec
user system total real
xlsxwriter 0.613193 0.000000 0.613193 ( 0.557582)
axlsx 19.055665 2.771983 21.827648 ( 17.259542)
Comparing this gem functionality to [axlsx](https://github.com/randym/axlsx) xlsxwriter lacks ability to read data from the current workbook state and does not have any integration with rails.