Skip to content

Instantly share code, notes, and snippets.

@randym
Created July 25, 2012 23:21
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save randym/3179305 to your computer and use it in GitHub Desktop.
Save randym/3179305 to your computer and use it in GitHub Desktop.
Example: Setting up auto filters / Table with axlsx
#Using Tables:
#This will add in the sorting filters for you as well as apply default table styling in excel.
#LibraOffice does the filters, but not the styling (as does Google docs if I recall correctly.)
#```ruby
wb.add_worksheet(:name => "Table") do |sheet|
sheet.add_row ["Build Matrix"]
sheet.add_row ["Build", "Duration", "Finished", "Rvm"]
sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
sheet.add_table "A2:D5", :name => 'Build Matrix'
end
#```
# Using Autofilter
# Same result without the styling
#```ruby
wb.add_worksheet(:name => "Auto Filter") do |sheet|
sheet.add_row ["Build Matrix"]
sheet.add_row ["Build", "Duration", "Finished", "Rvm"]
sheet.add_row ["19.1", "1 min 32 sec", "about 10 hours ago", "1.8.7"]
sheet.add_row ["19.2", "1 min 28 sec", "about 10 hours ago", "1.9.2"]
sheet.add_row ["19.3", "1 min 35 sec", "about 10 hours ago", "1.9.3"]
sheet.auto_filter = "A2:D5"
end
#```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment