diff options
Diffstat (limited to 'lib/axlsx/workbook/worksheet/pivot_table.rb')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/pivot_table.rb | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/lib/axlsx/workbook/worksheet/pivot_table.rb b/lib/axlsx/workbook/worksheet/pivot_table.rb index ed51d5cf..ff131dfb 100644 --- a/lib/axlsx/workbook/worksheet/pivot_table.rb +++ b/lib/axlsx/workbook/worksheet/pivot_table.rb @@ -11,12 +11,12 @@ module Axlsx # @param [Worksheet] sheet The sheet containing the table data. # @option options [Cell, String] name # @option options [TableStyle] style - def initialize(ref, range, sheet, options={}) + def initialize(ref, range, sheet, options = {}) @ref = ref self.range = range @sheet = sheet @sheet.workbook.pivot_tables << self - @name = "PivotTable#{index+1}" + @name = "PivotTable#{index + 1}" @data_sheet = nil @rows = [] @columns = [] @@ -122,7 +122,7 @@ module Axlsx @data = [] v.each do |data_field| if data_field.is_a? String - data_field = {:ref => data_field} + data_field = { :ref => data_field } end data_field.each do |key, value| if key == :num_fmt @@ -158,13 +158,13 @@ module Axlsx # The part name for this table # @return [String] def pn - "#{PIVOT_TABLE_PN % (index+1)}" + "#{PIVOT_TABLE_PN % (index + 1)}" end # The relationship part name of this pivot table # @return [String] def rels_pn - "#{PIVOT_TABLE_RELS_PN % (index+1)}" + "#{PIVOT_TABLE_RELS_PN % (index + 1)}" end # The cache_definition for this pivot table @@ -219,7 +219,7 @@ module Axlsx str << '<colFields count="1"><field x="-2"/></colFields>' str << "<colItems count=\"#{data.size}\">" str << '<i><x/></i>' - data[1..-1].each_with_index do |datum_value,i| + data[1..-1].each_with_index do |datum_value, i| str << "<i i=\"#{i + 1}\"><x v=\"#{i + 1}\"/></i>" end str << '</colItems>' @@ -244,7 +244,7 @@ module Axlsx str << "<dataFields count=\"#{data.size}\">" data.each do |datum_value| # The correct name prefix in ["Sum","Average", etc...] - str << "<dataField name='#{(datum_value[:subtotal]||'')} of #{datum_value[:ref]}' fld='#{header_index_of(datum_value[:ref])}' baseField='0' baseItem='0'" + str << "<dataField name='#{(datum_value[:subtotal] || '')} of #{datum_value[:ref]}' fld='#{header_index_of(datum_value[:ref])}' baseField='0' baseItem='0'" str << " numFmtId='#{datum_value[:num_fmt]}'" if datum_value[:num_fmt] str << " subtotal='#{datum_value[:subtotal]}' " if datum_value[:subtotal] str << "/>" @@ -254,7 +254,7 @@ module Axlsx # custom pivot table style unless style_info.empty? str << '<pivotTableStyleInfo' - style_info.each do |k,v| + style_info.each do |k, v| str << ' ' << k.to_s << '="' << v.to_s << '"' end str << ' />' |
