I am Using the Axlsx gem with rails to create the Excel sheet. I need the header to be fixed and frozen. The header to should be always visible even we scroll down. rails version 3.2.1 gem 'axlsx'
Any help is appreciated?
You can freeze the pane like this example:
require 'axlsx'
XLSX_temp = 'simple.xlsx'
Axlsx::Package.new do |p|
p.workbook.add_worksheet(:name => 'DATA') do |sheet|
sheet.add_row(%w{key col1 col2 col3 col4 col5})
#Fix first line and column
sheet.sheet_view.pane do |pane|
pane.top_left_cell = "B2"
pane.state = :frozen_split
pane.y_split = 1
pane.x_split = 1
pane.active_pane = :bottom_right
end
10.times{
sheet.add_row(%w{1 2 3 4 5 6})
}
end
puts "Write %s" % XLSX_temp
p.serialize(XLSX_temp)
end
The result has a fixed first column and row:

With pane.x_split = 0 only the first row is fixed.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With