summaryrefslogtreecommitdiffhomepage
path: root/examples/stream_example.md
diff options
context:
space:
mode:
Diffstat (limited to 'examples/stream_example.md')
-rw-r--r--examples/stream_example.md24
1 files changed, 24 insertions, 0 deletions
diff --git a/examples/stream_example.md b/examples/stream_example.md
new file mode 100644
index 00000000..409cc8fb
--- /dev/null
+++ b/examples/stream_example.md
@@ -0,0 +1,24 @@
+## Description
+
+You could serialize the package into a stream instead of writing to a file directly.
+
+## Code
+
+```ruby
+require 'axlsx'
+
+p = Axlsx::Package.new
+wb = p.workbook
+
+wb.add_worksheet(name: 'Basic Worksheet') do |sheet|
+ sheet.add_row ['First', 'Second', 'Third']
+ sheet.add_row [1, 2, 3]
+end
+
+stream = p.to_stream
+File.open('stream_example.xlsx', 'w') { |f| f.write(stream.read) }
+```
+
+## Output
+
+No difference should be visible