summaryrefslogtreecommitdiffhomepage
path: root/examples/stream_example.md
blob: 409cc8fbb9ac72eb3d6898f50ea2222d753cda00 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
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