Class: Xlsxrb::Elements::Formula

Inherits:
Data
  • Object
show all
Defined in:
lib/xlsxrb/elements/types.rb,
sig/generated/xlsxrb/elements/types.rbs

Overview

Represents an Excel formula with an optional cached value and calculation properties.

Examples:

Create a formula

formula = Elements::Formula.new(expression: "SUM(A1:A10)")

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(expression:, cached_value: nil, type: nil, ref: nil, shared_index: nil, calculate_always: nil, aca: nil, bx: nil, dt2d: nil, dtr: nil, r1: nil, r2: nil) ⇒ Formula

Returns a new instance of Formula.

Signature:

  • (expression: String, ?cached_value: untyped, ?type: untyped, ?ref: String?, ?shared_index: Integer?, ?calculate_always: bool?, ?aca: bool?, ?bx: bool?, ?dt2d: bool?, ?dtr: bool?, ?r1: String?, ?r2: String?) -> void

Parameters:

  • expression (String)

    Excel formula expression without leading '=' (e.g. "SUM(A1:A10)").

  • cached_value (Object, nil) (defaults to: nil)

    Optional precomputed value.

  • type (Symbol, String, nil) (defaults to: nil)

    Formula type (:shared, :array, etc.).

  • ref (String, nil) (defaults to: nil)

    Target cell or range reference.

  • shared_index (Integer, nil) (defaults to: nil)

    Shared formula index.

  • calculate_always (Boolean, nil) (defaults to: nil)

    Force Excel to recalculate on open.

  • aca (Boolean, nil) (defaults to: nil)

    Always calculate array attribute.

  • bx (Boolean, nil) (defaults to: nil)

    Assigns to array formula.

  • dt2d (Boolean, nil) (defaults to: nil)

    2D data table reference.

  • dtr (Boolean, nil) (defaults to: nil)

    1D data table reference.

  • r1 (String, nil) (defaults to: nil)

    First table reference.

  • r2 (String, nil) (defaults to: nil)

    Second table reference.



31
32
33
# File 'lib/xlsxrb/elements/types.rb', line 31

def initialize(expression:, cached_value: nil, type: nil, ref: nil, shared_index: nil, calculate_always: nil, aca: nil, bx: nil, dt2d: nil, dtr: nil, r1: nil, r2: nil) # rubocop:disable Naming/MethodParameterName
  super
end

Instance Attribute Details

#acaObject (readonly)

Returns the value of attribute aca

Returns:

  • (Object)

    the current value of aca



17
18
19
# File 'lib/xlsxrb/elements/types.rb', line 17

def aca
  @aca
end

#bxObject (readonly)

Returns the value of attribute bx

Returns:

  • (Object)

    the current value of bx



17
18
19
# File 'lib/xlsxrb/elements/types.rb', line 17

def bx
  @bx
end

#cached_valueObject (readonly)

Returns the value of attribute cached_value

Returns:

  • (Object)

    the current value of cached_value



17
18
19
# File 'lib/xlsxrb/elements/types.rb', line 17

def cached_value
  @cached_value
end

#calculate_alwaysObject (readonly)

Returns the value of attribute calculate_always

Returns:

  • (Object)

    the current value of calculate_always



17
18
19
# File 'lib/xlsxrb/elements/types.rb', line 17

def calculate_always
  @calculate_always
end

#dt2dObject (readonly)

Returns the value of attribute dt2d

Returns:

  • (Object)

    the current value of dt2d



17
18
19
# File 'lib/xlsxrb/elements/types.rb', line 17

def dt2d
  @dt2d
end

#dtrObject (readonly)

Returns the value of attribute dtr

Returns:

  • (Object)

    the current value of dtr



17
18
19
# File 'lib/xlsxrb/elements/types.rb', line 17

def dtr
  @dtr
end

#expressionObject (readonly)

Returns the value of attribute expression

Returns:

  • (Object)

    the current value of expression



17
18
19
# File 'lib/xlsxrb/elements/types.rb', line 17

def expression
  @expression
end

#r1Object (readonly)

Returns the value of attribute r1

Returns:

  • (Object)

    the current value of r1



17
18
19
# File 'lib/xlsxrb/elements/types.rb', line 17

def r1
  @r1
end

#r2Object (readonly)

Returns the value of attribute r2

Returns:

  • (Object)

    the current value of r2



17
18
19
# File 'lib/xlsxrb/elements/types.rb', line 17

def r2
  @r2
end

#refObject (readonly)

Returns the value of attribute ref

Returns:

  • (Object)

    the current value of ref



17
18
19
# File 'lib/xlsxrb/elements/types.rb', line 17

def ref
  @ref
end

#shared_indexObject (readonly)

Returns the value of attribute shared_index

Returns:

  • (Object)

    the current value of shared_index



17
18
19
# File 'lib/xlsxrb/elements/types.rb', line 17

def shared_index
  @shared_index
end

#typeObject (readonly)

Returns the value of attribute type

Returns:

  • (Object)

    the current value of type



17
18
19
# File 'lib/xlsxrb/elements/types.rb', line 17

def type
  @type
end

Class Method Details

.members[ :expression, :cached_value, :type, :ref, :shared_index, :calculate_always, :aca, :bx, :dt2d, :dtr, :r1, :r2 ]

Returns:

  • ([ :expression, :cached_value, :type, :ref, :shared_index, :calculate_always, :aca, :bx, :dt2d, :dtr, :r1, :r2 ])


45
# File 'sig/generated/xlsxrb/elements/types.rbs', line 45

def self.members: () -> [ :expression, :cached_value, :type, :ref, :shared_index, :calculate_always, :aca, :bx, :dt2d, :dtr, :r1, :r2 ]

.new(expression, cached_value, type, ref, shared_index, calculate_always, aca, bx, dt2d, dtr, r1, r2) ⇒ instance .new(expression:, cached_value:, type:, ref:, shared_index:, calculate_always:, aca:, bx:, dt2d:, dtr:, r1:, r2:) ⇒ instance

Overloads:

  • .new(expression, cached_value, type, ref, shared_index, calculate_always, aca, bx, dt2d, dtr, r1, r2) ⇒ instance

    Parameters:

    • expression (Object)
    • cached_value (Object)
    • type (Object)
    • ref (Object)
    • shared_index (Object)
    • calculate_always (Object)
    • aca (Object)
    • bx (Object)
    • dt2d (Object)
    • dtr (Object)
    • r1 (Object)
    • r2 (Object)

    Returns:

    • (instance)
  • .new(expression:, cached_value:, type:, ref:, shared_index:, calculate_always:, aca:, bx:, dt2d:, dtr:, r1:, r2:) ⇒ instance

    Parameters:

    • expression: (Object)
    • cached_value: (Object)
    • type: (Object)
    • ref: (Object)
    • shared_index: (Object)
    • calculate_always: (Object)
    • aca: (Object)
    • bx: (Object)
    • dt2d: (Object)
    • dtr: (Object)
    • r1: (Object)
    • r2: (Object)

    Returns:

    • (instance)


42
43
# File 'sig/generated/xlsxrb/elements/types.rbs', line 42

def self.new: (untyped expression, untyped cached_value, untyped type, untyped ref, untyped shared_index, untyped calculate_always, untyped aca, untyped bx, untyped dt2d, untyped dtr, untyped r1, untyped r2) -> instance
| (expression: untyped, cached_value: untyped, type: untyped, ref: untyped, shared_index: untyped, calculate_always: untyped, aca: untyped, bx: untyped, dt2d: untyped, dtr: untyped, r1: untyped, r2: untyped) -> instance

Instance Method Details

#members[ :expression, :cached_value, :type, :ref, :shared_index, :calculate_always, :aca, :bx, :dt2d, :dtr, :r1, :r2 ]

Returns:

  • ([ :expression, :cached_value, :type, :ref, :shared_index, :calculate_always, :aca, :bx, :dt2d, :dtr, :r1, :r2 ])


47
# File 'sig/generated/xlsxrb/elements/types.rbs', line 47

def members: () -> [ :expression, :cached_value, :type, :ref, :shared_index, :calculate_always, :aca, :bx, :dt2d, :dtr, :r1, :r2 ]