From 036f5883939a91fbc3eb377d968d85500dc3098a Mon Sep 17 00:00:00 2001 From: Alex Rothenberg Date: Tue, 27 Nov 2012 13:45:31 -0500 Subject: 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 --- examples/pivot_table.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'examples') 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 -- cgit v1.2.3