randym / axlsx

xlsx generation with charts, images, automated column width, customizable styles and full schema validation. Axlsx excels at helping you generate beautiful Office Open XML Spreadsheet documents without having to understand the entire ECMA specification. Check out the README for some examples of how easy it is. Best of all, you can validate your xlsx file before serialization so you know for sure that anything generated is going to load on your client's machine.
MIT License
2.62k stars 695 forks source link

Freeze Panes is not working #413

Open raghavendra-prithvi opened 9 years ago

raghavendra-prithvi commented 9 years ago

Hi, I have seen all the library code and I didn't find any code or existing method to use for the freeze top row. I need the header to be frozen for my application. Can anyone help me with this?

Thanks, Raghavendra

ruckus commented 8 years ago

The OOXML spec for Excel (and friends) is so large that I dont expect this library to have documented all the various options.

Fortunately, because an Excel xslx file is really just a zipped set of XML files, I have found that I can reverse engineer the needed Ruby calls by generating an Excel doc (in Excel) and then inspecting the resultant XML and translating those calls to Axlsx method calls.

I have written a blog post about how to do this here: http://ruckus.tumblr.com/post/125987714941/reverse-engineering-excel-xml

jontyD commented 8 years ago

Hi discovered panes need selections too in excel 2013 - axslx selections don not seem well documented but got this working as per below

freeze panes in right place

@sheet.sheet_view.pane do |pane|
  pane.top_left_cell = "C9"
  pane.state = :frozen
  pane.x_split = 2
  pane.y_split = 8
  pane.active_pane = :bottom_right
end
@sheet.sheet_view.add_selection :top_right  , :active_cell => "C1", :sqref => "C1"
@sheet.sheet_view.add_selection :bottom_left  , :active_cell => "A9", :sqref => "A9"
@sheet.sheet_view.add_selection :bottom_right  , :active_cell => "C9", :sqref => "C9"