summaryrefslogtreecommitdiffhomepage
path: root/examples/auto_filter.rb
blob: b47082cbe216cb22968006e751bd85c356226671 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
#!/usr/bin/env ruby -w -s
# -*- coding: utf-8 -*-

$LOAD_PATH.unshift "#{File.dirname(__FILE__)}/../lib"
require 'axlsx'
Axlsx::Package.new do |p|
  p.workbook.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.auto_filter = 'A2:D5'
    sheet.auto_filter.add_column 3, :filters, :filter_items => ['1.9.2']
  end
  p.workbook.add_worksheet(:name => "Table 2") 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'
    sheet.auto_filter.add_column 3, :filters, :filter_items => ['1.9.2']
  end
end.serialize('auto_filter.xlsx')