Current section
15 Versions
Jump to
Current section
15 Versions
Compare versions
6
files changed
+19
additions
-13
deletions
| @@ -2,6 +2,11 @@ | |
| 2 2 | |
| 3 3 | ## Unreleased |
| 4 4 | |
| 5 | + ## 0.6.0 |
| 6 | + |
| 7 | + - `Exceed.stream!` accepts a `buffer` option, which defaults to `true` and disables buffering when set to `false`, |
| 8 | + which may be more performant in certain situations. |
| 9 | + |
| 5 10 | ## 0.5.0 |
| 6 11 | |
| 7 12 | - Handle booleans with `t="b"`. |
| @@ -10,7 +10,7 @@ building spreadsheets. | |
| 10 10 | ``` elixir |
| 11 11 | def deps do |
| 12 12 | [ |
| 13 | - {:exceed, "~> 0.1"} |
| 13 | + {:exceed, "~> 0.6"} |
| 14 14 | ] |
| 15 15 | end |
| 16 16 | ``` |
| @@ -1,6 +1,6 @@ | |
| 1 1 | {<<"links">>,[{<<"GitHub">>,<<"https://github.com/synchronal/exceed">>}]}. |
| 2 2 | {<<"name">>,<<"exceed">>}. |
| 3 | - {<<"version">>,<<"0.5.0">>}. |
| 3 | + {<<"version">>,<<"0.6.0">>}. |
| 4 4 | {<<"description">>, |
| 5 5 | <<"A high-level stream-oriented MS Excel OpenXML (`.xlsx`) generator">>}. |
| 6 6 | {<<"elixir">>,<<"~> 1.16">>}. |
| @@ -24,9 +24,12 @@ defmodule Exceed do | |
| 24 24 | @doc """ |
| 25 25 | Convert an `Exceed.Workbook` to a stream. See `Exceed.Workbook.new/1`, |
| 26 26 | `Exceed.Worksheet.new/4`, and `Exceed.Workbook.add_worksheet/2`. |
| 27 | + |
| 28 | + The only option at the moment is `buffer` which can be set to `true` (the default) |
| 29 | + or to `false` (which may be more performant in some situations). |
| 27 30 | """ |
| 28 | - @spec stream!(Exceed.Workbook.t()) :: Enum.t() |
| 29 | - def stream!(%Exceed.Workbook{} = wb) do |
| 31 | + @spec stream!(Exceed.Workbook.t(), keyword()) :: Enum.t() |
| 32 | + def stream!(%Exceed.Workbook{} = wb, opts \\ []) do |
| 30 33 | wb = Exceed.Workbook.finalize(wb) |
| 31 34 | |
| 32 35 | [ |
| @@ -40,14 +43,14 @@ defmodule Exceed do | |
| 40 43 | {Exceed.SharedStrings.to_xml(), "xl/sharedStrings.xml"} |
| 41 44 | | worksheets_to_files(wb.worksheets) |
| 42 45 | ] |
| 43 | - |> Enum.map(&to_file/1) |
| 46 | + |> Enum.map(&to_file(&1, opts)) |
| 44 47 | |> Zstream.zip() |
| 45 48 | end |
| 46 49 | |
| 47 50 | # # # |
| 48 51 | |
| 49 | - defp to_file({xml, filename}), |
| 50 | - do: Exceed.File.file(xml, filename) |
| 52 | + defp to_file({xml, filename}, opts), |
| 53 | + do: Exceed.File.file(xml, filename, opts) |
| 51 54 | |
| 52 55 | defp worksheets_to_files(worksheets) do |
| 53 56 | for {worksheet, i} <- Enum.with_index(worksheets, 1) do |
| @@ -3,11 +3,9 @@ defmodule Exceed.File do | |
| 3 3 | |
| 4 4 | @buffer_size_bytes 16 * 1024 |
| 5 5 | |
| 6 | - def file(content, filename) do |
| 7 | - stream = |
| 8 | - XmlStream.stream!(content, printer: XmlStream.Printer.Ugly) |
| 9 | - |> buffer() |
| 10 | - |
| 6 | + def file(content, filename, opts) do |
| 7 | + stream = XmlStream.stream!(content, printer: XmlStream.Printer.Ugly) |
| 8 | + stream = if Keyword.get(opts, :buffer, true), do: buffer(stream), else: stream |
| 11 9 | Zstream.entry(filename, stream) |
| 12 10 | end |
Loading more files…