summaryrefslogtreecommitdiffhomepage
path: root/examples/active_tab_example.md
blob: 25f8052335b285fe074f58c6c26dd27b8096790a (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
## Description

Book views let you specify which sheet the show as active when the user opens the work book as well as a bunch of other.

## 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

wb.add_worksheet(name: 'Second Worksheet') do |sheet|
  sheet.add_row ['First', 'Second', 'Third']
  sheet.add_row [1, 2, 3]
end

# The horizontal scrollbar will be smaller
# The second tab will be selected
wb.add_view tab_ratio: 800, active_tab: 1

p.serialize 'active_tab_example.xlsx'
```

## Output

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