Skip to content

Commit

Permalink
chore(examples): include examples for customized locking and single p…
Browse files Browse the repository at this point in the history
…rint area specification with defined names
  • Loading branch information
randym committed Feb 22, 2018
1 parent 5e1f560 commit 73d9477
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions examples/example.rb
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
examples << :mbcs
examples << :formula
examples << :auto_filter
examples << :sheet_protection
examples << :data_types
examples << :override_data_types
examples << :hyperlinks
Expand Down Expand Up @@ -585,17 +586,25 @@
wb.add_worksheet(:name => 'defined name') do |sheet|
sheet.add_row [1, 2, 17, '=FOOBAR']
wb.add_defined_name("'defined name'!$C1", :local_sheet_id => sheet.index, :name => 'FOOBAR')
wb.add_defined_name("'defined name'!$A$1:$C$1", :local_sheet_id => sheet.index, :name => '_xlnm.Print_Area')
end
end

# Sheet Protection and excluding cells from locking.
if examples.include? :sheet_protection
unlocked = wb.styles.add_style :locked => false
wb.add_worksheet(:name => 'Sheet Protection') do |sheet|
sheet.sheet_protection.password = 'fish'
sheet.add_row [1, 2 ,3] # These cells will be locked
sheet.add_row [4, 5, 6], :style => unlocked # these cells will not!
sheet.sheet_protection do |protection|
protection.password = 'fish'
protection.auto_filter = false
end

sheet.add_row [1, 2 ,3], :style => unlocked # These cells will be locked
sheet.add_row [4, 5, 6]
sheet.add_row [7, 8, 9]
sheet.auto_filter = "A1:C3"
end

end

##Specify page margins and other options for printing
Expand Down

0 comments on commit 73d9477

Please sign in to comment.