Class: Writexlsx::Worksheet::FormulaCellData
- Defined in:
- lib/write_xlsx/worksheet/cell_data.rb
Overview
:nodoc:
Constant Summary
Constants included from Constants
Constants::COL_MAX, Constants::ROW_MAX, Constants::SHEETNAME_MAX, Constants::STR_MAX
Constants included from Utility::Common
Utility::Common::PERL_TRUE_VALUES
Instance Attribute Summary collapse
-
#link_type ⇒ Object
readonly
Returns the value of attribute link_type.
-
#range ⇒ Object
readonly
Returns the value of attribute range.
-
#result ⇒ Object
readonly
Returns the value of attribute result.
-
#token ⇒ Object
readonly
Returns the value of attribute token.
-
#url ⇒ Object
readonly
Returns the value of attribute url.
Attributes inherited from CellData
Instance Method Summary collapse
- #data ⇒ Object
-
#initialize(formula, xf, result) ⇒ FormulaCellData
constructor
A new instance of FormulaCellData.
- #write_cell(worksheet, row, row_name, col) ⇒ Object
Methods inherited from CellData
#cell_attributes, #display_url_string?
Methods included from Utility::CellReference
#row_col_notation, #substitute_cellref, #xl_cell_to_rowcol, #xl_col_to_name, #xl_range, #xl_range_formula, #xl_rowcol_to_cell
Methods included from Utility::Common
#absolute_char, #check_parameter, #float_to_str, #ptrue?, #put_deprecate_message
Constructor Details
#initialize(formula, xf, result) ⇒ FormulaCellData
Returns a new instance of FormulaCellData.
98 99 100 101 102 |
# File 'lib/write_xlsx/worksheet/cell_data.rb', line 98 def initialize(formula, xf, result) @token = formula @xf = xf @result = result end |
Instance Attribute Details
#link_type ⇒ Object (readonly)
Returns the value of attribute link_type.
96 97 98 |
# File 'lib/write_xlsx/worksheet/cell_data.rb', line 96 def link_type @link_type end |
#range ⇒ Object (readonly)
Returns the value of attribute range.
96 97 98 |
# File 'lib/write_xlsx/worksheet/cell_data.rb', line 96 def range @range end |
#result ⇒ Object (readonly)
Returns the value of attribute result.
96 97 98 |
# File 'lib/write_xlsx/worksheet/cell_data.rb', line 96 def result @result end |
#token ⇒ Object (readonly)
Returns the value of attribute token.
96 97 98 |
# File 'lib/write_xlsx/worksheet/cell_data.rb', line 96 def token @token end |
#url ⇒ Object (readonly)
Returns the value of attribute url.
96 97 98 |
# File 'lib/write_xlsx/worksheet/cell_data.rb', line 96 def url @url end |
Instance Method Details
#data ⇒ Object
104 105 106 |
# File 'lib/write_xlsx/worksheet/cell_data.rb', line 104 def data @result || 0 end |
#write_cell(worksheet, row, row_name, col) ⇒ Object
108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/write_xlsx/worksheet/cell_data.rb', line 108 def write_cell(worksheet, row, row_name, col) truefalse = { 'TRUE' => 1, 'FALSE' => 0 } error_code = ['#DIV/0!', '#N/A', '#NAME?', '#NULL!', '#NUM!', '#REF!', '#VALUE!'] value = @result attributes = cell_attributes(worksheet, row, row_name, col) if value && !(value.to_s =~ /^([+-]?)(?=\d|\.\d)\d*(\.\d*)?([Ee]([+-]?\d+))?$/) if truefalse[value] attributes << %w[t b] value = truefalse[value] elsif error_code.include?(value) attributes << %w[t e] else attributes << %w[t str] end end worksheet.writer.tag_elements('c', attributes) do worksheet.write_cell_formula(token) worksheet.write_cell_value(value || 0) end end |