summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/workbook/worksheet/row.rb
diff options
context:
space:
mode:
authorjohnnyshields <[email protected]>2023-03-31 04:40:41 +0900
committerjohnnyshields <[email protected]>2023-03-31 04:40:41 +0900
commit0746815b75296bcf65d49a66f0dca1427ac65f3e (patch)
treedb99ace871993f5fa1bd80821527ab252a277d53 /lib/axlsx/workbook/worksheet/row.rb
parentc5ddbe7cd9bb15e8b247e6b5a5e359d02dd5b9fe (diff)
downloadcaxlsx-0746815b75296bcf65d49a66f0dca1427ac65f3e.tar.gz
caxlsx-0746815b75296bcf65d49a66f0dca1427ac65f3e.zip
Add settings for escape_formulas at global, workbook, worksheet, row and cell levels.
Diffstat (limited to 'lib/axlsx/workbook/worksheet/row.rb')
-rw-r--r--lib/axlsx/workbook/worksheet/row.rb18
1 files changed, 14 insertions, 4 deletions
diff --git a/lib/axlsx/workbook/worksheet/row.rb b/lib/axlsx/workbook/worksheet/row.rb
index 63a8d328..abef95cb 100644
--- a/lib/axlsx/workbook/worksheet/row.rb
+++ b/lib/axlsx/workbook/worksheet/row.rb
@@ -24,6 +24,7 @@ module Axlsx
# @option options [Array] values
# @option options [Array, Symbol] types
# @option options [Array, Integer] style
+ # @option options [Array, Boolean] escape_formulas
# @option options [Float] height the row's height (in points)
# @option options [Integer] offset - add empty columns before values
# @see Row#array_to_cells
@@ -104,20 +105,29 @@ module Axlsx
c
end
- # sets the color for every cell in this row
+ # Sets the color for every cell in this row.
def color=(color)
each_with_index do | cell, index |
cell.color = color.is_a?(Array) ? color[index] : color
end
end
- # sets the style for every cell in this row
+ # Sets the style for every cell in this row.
def style=(style)
each_with_index do | cell, index |
cell.style = style.is_a?(Array) ? style[index] : style
end
end
+ # Sets escape_formulas for every cell in this row. This determines whether to treat
+ # values starting with an equals sign as formulas or as literal strings.
+ # @param [Array, Boolean] value The value to set.
+ def escape_formulas=(value)
+ each_with_index do | cell, index |
+ cell.escape_formulas = value.is_a?(Array) ? value[index] : value
+ end
+ end
+
# @see height
def height=(v)
unless v.nil?
@@ -146,6 +156,7 @@ module Axlsx
# @option options [Array] values
# @option options [Array, Symbol] types
# @option options [Array, Integer] style
+ # @option options [Array, Boolean] escape_formulas
def array_to_cells(values, options={})
DataTypeValidator.validate :array_to_cells, Array, values
types, style, formula_values, escape_formulas, offset = options.delete(:types), options.delete(:style), options.delete(:formula_values), options.delete(:escape_formulas), options.delete(:offset)
@@ -153,12 +164,11 @@ module Axlsx
values.each_with_index do |value, index|
options[:style] = style.is_a?(Array) ? style[index] : style if style
options[:type] = types.is_a?(Array) ? types[index] : types if types
- options[:escape_formulas] = escape_formulas.is_a?(Array) ? escape_formulas[index] : escape_formulas if escape_formulas
+ options[:escape_formulas] = escape_formulas.is_a?(Array) ? escape_formulas[index] : escape_formulas unless escape_formulas.nil?
options[:formula_value] = formula_values[index] if formula_values.is_a?(Array)
self[index + offset.to_i] = Cell.new(self, value, options)
end
end
end
-
end