Exceed

Exceed is a high-level stream-oriented library for generating Excel files. Useful when generating spreadsheets from data sets large enough that they may exceed available memory—or at least the available memory that one might want to dedicate to building spreadsheets.

Installation

def deps do
  [
    {:exceed, "~> 0.1"}
  ]
end

Usage

XLSX streams are generated by initializing a workbook (with a creator name), adding worksheets, and then converting that to a stream.

stream =
  Exceed.Workbook.new("Creator Name")
  |> Exceed.Workbook.add_worksheet(
    Exceed.Worksheet.new("Sheet Name", ["Heading 1", "Heading 2"]
      [["Row 1 Cell 1", "Row 1 Cell 2"], ["Row 2 Cell 1", "Row 2 Cell 2"]])
  )
  |> Exceed.stream!()

stream
|> Stream.into(File.stream!("/tmp/workbook.xslx"))
|> Stream.run()

Worksheets may be initialized with lists of lists, or they may be initialized with a stream of data that maps to a list of cells.

rows =
  Stream.unfold(1, fn
    10_001 -> nil
    row_count -> {["Row #{row_count} Cell 1", "Row #{row_count} Cell 2"], row_count + 1}
  end)

Exceed.Worksheet.new("Sheet Name", ["Heading 1", "Heading 2"], rows)

Alternatives & References

This library is inspired by and learns from other great libraries. One may choose to use those instead of Exceed: