Class: Axlsx::DefinedName
- Inherits:
-
Object
- Object
- Axlsx::DefinedName
- Defined in:
- lib/axlsx/workbook/defined_name.rb
Overview
This element defines the defined names that are defined within this workbook. Defined names are descriptive text that is used to represents a cell, range of cells, formula, or constant value. Use easy-to-understand names, such as Products, to refer to hard to understand ranges, such as Sales!C20:C30. A defined name in a formula can make it easier to understand the purpose of the formula. Names are available to any sheet. Names can also be used to represent formulas or values that do not change (constants).
You can also link to a defined name in another workbook, or define a name that refers to cells in another workbook.
A compliant producer or consumer considers a defined name in the range A1-XFD1048576 to be an error. All other names outside this range can be defined as names and overrides a cell reference if an ambiguity exists.
Constant Summary collapse
- STRING_ATTRIBUTES =
string attributes that will be added when this class is evaluated
[:short_cut_key, :status_bar, :help, :description, :custom_menu, :comment]
- BOOLEAN_ATTRIBUTES =
boolean attributes that will be added when this class is evaluated
[:workbook_parameter, :publish_to_server, :xlm, :vb_proceedure, :function, :hidden]
Instance Attribute Summary collapse
-
#formula ⇒ Object
readonly
The formula this defined name references.
-
#local_sheet_id ⇒ Object
Returns the value of attribute local_sheet_id.
-
#name ⇒ Object
Returns the value of attribute name.
Instance Method Summary collapse
-
#initialize(formula, options = {}) ⇒ DefinedName
constructor
creates a new DefinedName.
- #to_xml_string(str = '') ⇒ Object
Constructor Details
#initialize(formula, options = {}) ⇒ DefinedName
creates a new DefinedName.
97 98 99 100 101 102 |
# File 'lib/axlsx/workbook/defined_name.rb', line 97 def initialize(formula, ={}) @formula = formula .each do |o| self.send("#{o[0]}=", o[1]) if self.respond_to? "#{o[0]}=" end end |
Instance Attribute Details
#formula ⇒ Object (readonly)
The formula this defined name references
160 161 162 |
# File 'lib/axlsx/workbook/defined_name.rb', line 160 def formula @formula end |
#local_sheet_id ⇒ Object
Returns the value of attribute local_sheet_id.
103 104 105 |
# File 'lib/axlsx/workbook/defined_name.rb', line 103 def local_sheet_id @local_sheet_id end |
#name ⇒ Object
Returns the value of attribute name.
152 153 154 |
# File 'lib/axlsx/workbook/defined_name.rb', line 152 def name @name end |
Instance Method Details
#to_xml_string(str = '') ⇒ Object
162 163 164 165 166 167 168 169 170 171 172 |
# File 'lib/axlsx/workbook/defined_name.rb', line 162 def to_xml_string(str='') raise ArgumentError, 'you must specify the name for this defined name. Please read the documentation for Axlsx::DefinedName for more details' unless name str << '<definedName' instance_values.each do |name, value| unless name == 'formula' str << ' ' << Axlsx::camel(name, false) << "='#{value}'" end end str << '>' << @formula str << '</definedName>' end |