Method: Writeexcel::Worksheet#set_h_pagebreaks
- Defined in:
- lib/writeexcel/worksheet.rb
#set_h_pagebreaks(breaks) ⇒ Object
Store the horizontal page breaks on a worksheet. breaks is Fixnum or Array of Fixnum.
Add horizontal page breaks to a worksheet. A page break causes all the data that follows it to be printed on the next page. Horizontal page breaks act between rows. To create a page break between rows 20 and 21 you must specify the break at row 21. However in zero index notation this is actually row 20. So you can pretend for a small while that you are using 1 index notation:
worksheet1.set_h_pagebreaks(20) # Break between row 20 and 21
The set_h_pagebreaks() method will accept a array of page breaks and you can call it more than once:
worksheet2.set_h_pagebreaks([ 20, 40, 60, 80, 100]) # Add breaks
worksheet2.set_h_pagebreaks([120, 140, 160, 180, 200]) # Add some more
Note: If you specify the “fit to page” option via the fit_to_pages() method it will override all manual page breaks.
There is a silent limitation of about 1000 horizontal page breaks per worksheet in line with an Excel internal limitation.
1868 1869 1870 |
# File 'lib/writeexcel/worksheet.rb', line 1868 def set_h_pagebreaks(breaks) @hbreaks += breaks.respond_to?(:to_ary) ? breaks : [breaks] end |