Class: Axlsx::PivotTableCacheDefinition
- Inherits:
-
Object
- Object
- Axlsx::PivotTableCacheDefinition
- Includes:
- OptionsParser
- Defined in:
- lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb
Overview
Note:
Worksheet#add_pivot_table is the recommended way to create tables for your worksheets.
Table
Instance Attribute Summary collapse
-
#pivot_table ⇒ Object
readonly
The reference to the pivot table data # @return [PivotTable].
Instance Method Summary collapse
-
#cache_id ⇒ Integer
The identifier for this cache.
-
#index ⇒ Integer
The index of this chart in the workbooks charts collection.
-
#initialize(pivot_table) ⇒ PivotTableCacheDefinition
constructor
Creates a new PivotTable object.
-
#pn ⇒ String
The part name for this table.
-
#rId ⇒ String
The relationship id for this pivot table cache definition.
-
#to_xml_string(str = '') ⇒ String
Serializes the object.
Methods included from OptionsParser
Constructor Details
#initialize(pivot_table) ⇒ PivotTableCacheDefinition
Creates a new PivotTable object
12 13 14 |
# File 'lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb', line 12 def initialize(pivot_table) @pivot_table = pivot_table end |
Instance Attribute Details
#pivot_table ⇒ Object (readonly)
The reference to the pivot table data
@return [PivotTable]
18 19 20 |
# File 'lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb', line 18 def pivot_table @pivot_table end |
Instance Method Details
#cache_id ⇒ Integer
The identifier for this cache
34 35 36 |
# File 'lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb', line 34 def cache_id index + 1 end |
#index ⇒ Integer
The index of this chart in the workbooks charts collection
22 23 24 |
# 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 ⇒ String
The part name for this table
28 29 30 |
# File 'lib/axlsx/workbook/worksheet/pivot_table_cache_definition.rb', line 28 def pn "#{PIVOT_TABLE_CACHE_DEFINITION_PN % (index+1)}" end |
#rId ⇒ String
The relationship id for this pivot table cache definition.
41 42 43 |
# 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 = '') ⇒ String
Serializes the object
48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
# 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 |