Created
December 14, 2012 10:15
-
-
Save randym/4284284 to your computer and use it in GitHub Desktop.
Collapsed outline level
This file contains hidden or 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 | |
wb.add_worksheet(name: 'outline_level') do |sheet| | |
sheet.add_row [1, 2, 3, 4, Time.now, 149455.15] | |
sheet.add_row [1, 2, 5, 6, Time.now,14100.19] | |
sheet.add_row [9500002267, 1212, 1212, Time.now,14100.19] | |
sheet.add_row [], :collapsed => 1 | |
sheet.rows[0..2].each do |row| | |
row.outline_level = 1 | |
# This will collapse the outline level rows | |
row.hidden = true | |
end | |
sheet.column_info[0..2].each do |col| | |
col.outline_level = 1 | |
#This will collapse the outline level cols | |
col.hidden = true | |
end | |
# This will show the show the [+] symbols | |
sheet.sheet_view do |view| | |
view.show_outline_symbols=true | |
end | |
end | |
#``` |
I'm thinking this could be made a bit easier by adding something to worksheet like:
def outline_rows(start_index, end_index, level = 1, collapsed = true
So Ive added two helper methods to worksheet.
You can do the same thing as you have above by calling
sheet.outline_rows (sheet.rows.size - rows_data_array.size), sheet.rows.size
It will enable the outline symbols and collapse the rows by default.
Ive added a similar method for outline_columns as well.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeahh its perfect. I was trying collapsed http://rubydoc.info/github/randym/axlsx/Axlsx/Col#collapsed-instance_method. Thanks !
Notice that as I make loops over summary rows, I have to set outline and hidden to n lasts rows and it seems that
sheet.rows[-n..0].each
does not work. I had to do :