class Axlsx::PivotTableCacheDefinition
Table
@note Worksheet#add_pivot_table
is the recommended way to create tables for your worksheets. @see README for examples
Attributes
pivot_table[R]
The reference to the pivot table data @return [PivotTable]
Public Class Methods
new(pivot_table)
click to toggle source
Creates a new PivotTable
object @param [String] pivot_table
The pivot table this cache definition is in
# File lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb, line 12 def initialize(pivot_table) @pivot_table = pivot_table end
Public Instance Methods
cache_id()
click to toggle source
The identifier for this cache @return [Integer]
# File lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb, line 34 def cache_id index + 1 end
index()
click to toggle source
The index of this chart in the workbooks charts collection @return [Integer]
# File lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb, line 22 def index pivot_table.sheet.workbook.pivot_tables.index(pivot_table) end
pn()
click to toggle source
The part name for this table @return [String]
# File lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb, line 28 def pn "#{PIVOT_TABLE_CACHE_DEFINITION_PN % (index+1)}" end
rId()
click to toggle source
The relationship id for this pivot table cache definition. @see Relationship#Id @return [String]
# File lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb, line 41 def rId pivot_table.relationships.for(self).Id end
to_xml_string(str = '')
click to toggle source
Serializes the object @param [String] str @return [String]
# File lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb, line 48 def to_xml_string(str = '') str << '<?xml version="1.0" encoding="UTF-8"?>' str << ('<pivotCacheDefinition xmlns="' << XML_NS << '" xmlns:r="' << XML_NS_R << '" invalid="1" refreshOnLoad="1" recordCount="0">') str << '<cacheSource type="worksheet">' str << ( '<worksheetSource ref="' << pivot_table.range << '" sheet="' << pivot_table.data_sheet.name << '"/>') str << '</cacheSource>' str << ( '<cacheFields count="' << pivot_table.header_cells_count.to_s << '">') pivot_table.header_cells.each do |cell| str << ( '<cacheField name="' << cell.value << '" numFmtId="0">') str << '<sharedItems count="0">' str << '</sharedItems>' str << '</cacheField>' end str << '</cacheFields>' str << '</pivotCacheDefinition>' end