All Projects → felixbuenemann → Xlsxtream

felixbuenemann / Xlsxtream

Licence: mit
Streaming & Fast XLSX Spreadsheet Writer for Ruby

Programming Languages

ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to Xlsxtream

Node Csv
Full featured CSV parser with simple api and tested against large datasets.
Stars: ✭ 3,068 (+1567.39%)
Mutual labels:  csv, streaming
Node Csv Stringify
CSV stringifier implementing the Node.js `stream.Transform` API
Stars: ✭ 179 (-2.72%)
Mutual labels:  csv, streaming
Csvutil
csvutil provides fast and idiomatic mapping between CSV and Go (golang) values.
Stars: ✭ 501 (+172.28%)
Mutual labels:  csv, streaming
CSV2RDF
Streaming, transforming, SPARQL-based CSV to RDF converter. Apache license.
Stars: ✭ 48 (-73.91%)
Mutual labels:  streaming, csv
Loaders.gl
Loaders for big data visualization. Website:
Stars: ✭ 272 (+47.83%)
Mutual labels:  csv, streaming
Stream Parser
⚡ PHP7 / Laravel Multi-format Streaming Parser
Stars: ✭ 391 (+112.5%)
Mutual labels:  csv, streaming
Node Csv Parse
CSV parsing implementing the Node.js `stream.Transform` API
Stars: ✭ 768 (+317.39%)
Mutual labels:  csv, streaming
Koel
🐦 A personal music streaming server that works.
Stars: ✭ 13,105 (+7022.28%)
Mutual labels:  streaming
Django Import Export
Django application and library for importing and exporting data with admin integration.
Stars: ✭ 2,265 (+1130.98%)
Mutual labels:  csv
Onyx
Distributed, masterless, high performance, fault tolerant data processing
Stars: ✭ 2,019 (+997.28%)
Mutual labels:  streaming
Covid 19 Uk Data
Coronavirus (COVID-19) UK Historical Data
Stars: ✭ 169 (-8.15%)
Mutual labels:  csv
Tus Ruby Server
Ruby server for tus resumable upload protocol
Stars: ✭ 172 (-6.52%)
Mutual labels:  streaming
Github Csv Tools
Import and export GitHub issues via CSV
Stars: ✭ 182 (-1.09%)
Mutual labels:  csv
Render Media
Intelligently render media files in the browser
Stars: ✭ 181 (-1.63%)
Mutual labels:  streaming
Cakephp Csvview
CakePHP: A view class for generating CSV
Stars: ✭ 174 (-5.43%)
Mutual labels:  csv
Logstash
Logstash - transport and process your logs, events, or other data
Stars: ✭ 12,543 (+6716.85%)
Mutual labels:  streaming
Scio
A Scala API for Apache Beam and Google Cloud Dataflow.
Stars: ✭ 2,247 (+1121.2%)
Mutual labels:  streaming
Csvreader
csvreader library / gem - read tabular data in the comma-separated values (csv) format the right way (uses best practices out-of-the-box with zero-configuration)
Stars: ✭ 169 (-8.15%)
Mutual labels:  csv
Liftbridge
Lightweight, fault-tolerant message streams.
Stars: ✭ 2,175 (+1082.07%)
Mutual labels:  streaming
Hstream
The streaming database built for IoT data storage and real-time processing in the 5G Era
Stars: ✭ 166 (-9.78%)
Mutual labels:  streaming

Xlsxtream

Gem Version Build Status

Xlsxtream is a streaming writer for XLSX spreadsheets. It supports multiple worksheets and optional string deduplication via a shared string table (SST). Its purpose is to replace CSV for large exports, because using CSV in Excel is very buggy and error prone. It's very efficient and can quickly write millions of rows with low memory usage.

Xlsxtream does not support formatting, charts, comments and a myriad of other OOXML features. If you are looking for a fully featured solution take a look at caxslx.

Xlsxtream supports writing to files or IO-like objects, data is flushed as the ZIP compressor sees fit.

Installation

Add this line to your application's Gemfile:

gem 'xlsxtream'

And then execute:

$ bundle

Or install it yourself as:

$ gem install xlsxtream

Usage

# Creates a new workbook and closes it at the end of the block
Xlsxtream::Workbook.open('my_data.xlsx') do |xlsx|
  xlsx.write_worksheet 'Sheet1' do |sheet|
    # Boolean, Date, Time, DateTime and Numeric are properly mapped
    sheet << [true, Date.today, 'hello', 'world', 42, 3.14159265359, 42**13]
  end
end

io = StringIO.new
xlsx = Xlsxtream::Workbook.new(io)

# Number of columns doesn't have to match
xlsx.write_worksheet 'Sheet1' do |sheet|
  sheet << ['first', 'row']
  sheet << ['second', 'row', 'with', 'more colums']
end

# Write multiple worksheets with custom names
xlsx.write_worksheet 'AppendixSheet' do |sheet|
  sheet.add_row ['Timestamp', 'Comment']
  sheet.add_row [Time.now, 'Good times']
  sheet.add_row [Time.now, 'Time-machine']
end

# If you have highly repetitive data, you can enable Shared String Tables (SST)
# for the workbook or a single worksheet. The SST has to be kept in memory,
# so do not use it if you have a huge amount of rows or a little duplication
# of content across cells. A single SST is used for the whole workbook.
xlsx.write_worksheet(name: 'SheetWithSST', use_shared_strings: true) do |sheet|
  sheet << ['the', 'same', 'old', 'story']
  sheet << ['the', 'old', 'same', 'story']
  sheet << ['old', 'the', 'same', 'story']
end

# Strings in numeric or date/time format can be auto-detected and formatted
# appropriately. This is a convenient way to avoid an Excel-warning about
# "Number stored as text". Dates and times must be in the ISO-8601 format and
# numeric values must contain only numbers and an optional decimal separator.
# The strings true and false are detected as boolean values.
xlsx.write_worksheet(name: 'SheetWithAutoFormat', auto_format: true) do |sheet|
  # these two rows will be identical in the xlsx-output
  sheet << [true, 11.85, DateTime.parse('2050-01-01T12:00'), Date.parse('1984-01-01')]
  sheet << ['true', '11.85', '2050-01-01T12:00', '1984-01-01']
end

# You can also create worksheet without a block, using the `add_worksheet` method.
# It can be only used sequentially, so remember to manually close the worksheet
# when you are done (before opening a new one).
worksheet = xls.add_worksheet(name: 'SheetWithoutBlock')
worksheet << ['some', 'data']
worksheet.close

# Writes metadata and ZIP archive central directory
xlsx.close
# Close IO object
io.close

# Changing the default font from Calibri, 12pt, Swiss
Xlsxtream::Workbook.new(io, font: {
  name: 'Times New Roman',
  size: 10, # size in pt
  family: 'Roman' # Swiss, Modern, Script, Decorative
})

# Specifying column widths in pixels or characters; 3 column example;
# "pixel" widths appear to be *relative* to an assumed 11pt Calibri
# font, so if selecting a different font or size (see above), do not
# adjust widths to match. Calculate pixel widths for 11pt Calibri.
Xlsxtream::Workbook.new(io, columns: [
  { width_pixels: 33 },
  { width_chars: 7 },
  { width_chars: 24 }
])
# The :columns option can also be given to write_worksheet, so it's
# possible to have multiple worksheets with different column widths.

Compatibility

The current version of Xlsxtream requires at least Ruby 2.1.0.

If you are using an older Ruby version you can use the following in your Gemfile:

gem 'xlsxtream', '< 2'
  • The last version with support for Ruby 1.9.1 is 1.2.0.
  • The last version with support for Ruby 1.9.2 is 1.3.2.

Upgrading

If you are upgrading from a version earlier than 2.x and are using the undocumented :io_wrapper option you need to update your code:

# Pre 2.x code with :io_wrapper option
Xlsxtream::Workbook.new(io, io_wrapper: MyCustomIOWrapper)
# New code with IO wrapper instance
io_wrapper = MyCustomIOWrapper.new(io)
Xlsxtream::Workbook.new(io_wrapper)

Every IO-like object that responds to :add_file is treated as an IO wrapper.

Development

After checking out the repo, run bin/setup to install dependencies. Then, run rake test to run the tests. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/felixbuenemann/xlsxtream.

License

The gem is available as open source under the terms of the MIT License.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].