diff options
| author | Alex Rothenberg <[email protected]> | 2012-11-27 13:45:31 -0500 |
|---|---|---|
| committer | Alex Rothenberg <[email protected]> | 2012-11-27 14:16:55 -0500 |
| commit | 036f5883939a91fbc3eb377d968d85500dc3098a (patch) | |
| tree | 05133197c66091590840da3ed2fe3812eb3143aa /examples | |
| parent | 4560bd0a1b8b46bf4d8c0783f9fa12e8ceee714f (diff) | |
| download | caxlsx-036f5883939a91fbc3eb377d968d85500dc3098a.tar.gz caxlsx-036f5883939a91fbc3eb377d968d85500dc3098a.zip | |
Can configure a pivot table when creating it
see examples/pivot_table.rb
wb.add_worksheet(:name => "Data Sheet") do |sheet|
sheet.add_row ['Month', 'Year', 'Type', 'Sales', 'Region']
30.times { sheet.add_row [month, year, type, sales, region] }
sheet.add_pivot_table 'G4:L17', "A1:E31" do |pivot_table|
pivot_table.rows = ['Month', 'Year']
pivot_table.columns = ['Type']
pivot_table.data = ['Sales']
pivot_table.pages = ['Region']
end
end
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/pivot_table.rb | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/examples/pivot_table.rb b/examples/pivot_table.rb index 229ed8c9..07d03d55 100644 --- a/examples/pivot_table.rb +++ b/examples/pivot_table.rb @@ -27,7 +27,12 @@ end wb.add_worksheet(:name => "Data Sheet") do |sheet| sheet.add_row ['Month', 'Year', 'Type', 'Sales', 'Region'] 30.times { sheet.add_row [month, year, type, sales, region] } - sheet.add_pivot_table 'G4:L17', "A1:E31" + sheet.add_pivot_table 'G4:L17', "A1:E31" do |pivot_table| + pivot_table.rows = ['Month', 'Year'] + pivot_table.columns = ['Type'] + pivot_table.data = ['Sales'] + pivot_table.pages = ['Region'] + end end # Write the excel file |
