summaryrefslogtreecommitdiffhomepage
path: root/examples/column_widths_example.md
blob: 5d94090d1b70277b871a6982b6d7c000e2732ee9 (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
25
26
27
28
29
30
31
32
33
34
## Description

You can set the column widths

## Code

```ruby
require 'axlsx'

p = Axlsx::Package.new
wb = p.workbook

wb.add_worksheet(name: 'Column widths') do |sheet|
  sheet.add_row [
    'I use autowidth and am very wide',
    'I use a custom width and am narrow'
  ]

  sheet.add_row [
    'abcdefg',
    'This is a very long text and should flow into the right cell',
    nil,
    'xxx'
  ]

  sheet.column_widths nil, 3, 5, nil
end

p.serialize 'column_widths_example.xlsx'
```

## Output

![Output](images/column_widths_example.png "Output")