Created
July 31, 2012 04:09
-
-
Save randym/3213525 to your computer and use it in GitHub Desktop.
Excel with Ruby: Printing Header Row for every page with axlsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#```ruby | |
require 'axlsx' | |
p = Axlsx::Package.new | |
wb = p.workbook | |
wb.add_worksheet(:name => "repeated header") do |sheet| | |
sheet.add_row %w(These Column Header Will Render On Every Printed Sheet) | |
200.times { sheet.add_row %w(1 2 3 4 5 6 7 8) } | |
# This is the magic | |
wb.add_defined_name("'repeated header'!$1:$1", :local_sheet_id => sheet.index, :name => '_xlnm.Print_Titles') | |
end | |
p.serialize 'repeating_headers.xlsx' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, which version if ruby and axls were you using?
It does not work for me with axlsx 0.2.0. The header does not repeat in print preview.
Thanks.