Keep the header row from scrolling
MadBomber opened this issue · 5 comments
It is not obvious to me switch style to use in the header style has to cause the header ro to be fixed non-scrolling. I thought maybe it was locked
but that did not work; nor did it keep a user from changing the content of a cell in the header row.
Does spreadsheet_architect support this capability?
In stack overflow this question is asked of axlsx with the following answer:
`
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
`
Assuming this works, what is the equivalent SSA api?``
To summarize, the features you desire are:
- Lock cells / Disallow changing of cell contents
- Frozen / Non-scrolling Header capability
- Other general frozen panes support
I have not implemented any capability regarding panes. Can you point me to the documentation for this?
That being said, Spreadsheet Architect is a high level abstraction ontop of Axlsx. For more low level capabilities you may need to break down and use Axlsx directly.
Thank you for the quick response. My specific interest is just the non-scrolling header row. As a high-level abstraction SSA is a wonderful product. I'm deep into its code now as well as axlsx and axlsx_styles. The only documentation I have is the stack overflow entry:
https://stackoverflow.com/questions/32148704/unable-to-freeze-the-header-pane-using-axlsx-with-rails
I just created a pull request that implements the header_style option of fixed_top_left which when true will prevent the header row and the first column (most left) from scrolling. This does what I need for my application.
It just occurred to me that there was not error check for when the header_style
option hash was not present.
pused the change that traps for when header_style is not present.
The :freeze
and :freeze_headers
options have now been implemented in master. @MadBomber please test the changes to see if they work for you.
For now the freezing is limited to the top and/or left portions of the spreadsheet (active_pane: :bottom_right
).
At this time I was unable to come up with a working implementation that allows to specify alternative :active_pane
. PR Wanted. All available Axlsx options for :active_pane
are:
:bottom_right
- Default mode, currently locked to this mode of freeze:bottom_left
:top_left
:top_right
PR Wanted for :active_pane
to support more of the above values. See the following to get started.
spreadsheet_architect/lib/spreadsheet_architect/class_methods/xlsx.rb
Lines 220 to 226 in a8febce