summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx/workbook/worksheet/cell_serializer.rb
diff options
context:
space:
mode:
authortafryn <[email protected]>2014-03-03 16:29:06 -0800
committertafryn <[email protected]>2014-03-03 16:29:06 -0800
commit87cd49d0b8ab08c251368e89cdd9cb1f1eedbd4e (patch)
tree1f814aee4633fb10222a3e1c63973d4609917a2e /lib/axlsx/workbook/worksheet/cell_serializer.rb
parent2bee5b68dd51f397e5b39cdf52a5801bc863dbab (diff)
downloadcaxlsx-87cd49d0b8ab08c251368e89cdd9cb1f1eedbd4e.tar.gz
caxlsx-87cd49d0b8ab08c251368e89cdd9cb1f1eedbd4e.zip
Add support for array formulas.
Diffstat (limited to 'lib/axlsx/workbook/worksheet/cell_serializer.rb')
-rw-r--r--lib/axlsx/workbook/worksheet/cell_serializer.rb13
1 files changed, 12 insertions, 1 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell_serializer.rb b/lib/axlsx/workbook/worksheet/cell_serializer.rb
index 0f66c53e..81ae11de 100644
--- a/lib/axlsx/workbook/worksheet/cell_serializer.rb
+++ b/lib/axlsx/workbook/worksheet/cell_serializer.rb
@@ -95,6 +95,15 @@ module Axlsx
str << ('<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil?
end
+ # Serializes cells that are type array formula
+ # @param [Cell] cell The cell that is being serialized
+ # @param [String] str The string the serialized content will be appended to.
+ # @return [String]
+ def array_formula_serialization(cell, str='')
+ str << ('t="str">' << '<f t="array" ref="' << cell.r << '">' << cell.value.to_s.sub('{=', '').sub(/}$/, '') << '</f>')
+ str << ('<v>' << cell.formula_value.to_s << '</v>') unless cell.formula_value.nil?
+ end
+
# Serializes cells that are type inline_string
# @param [Cell] cell The cell that is being serialized
# @param [String] str The string the serialized content will be appended to.
@@ -110,7 +119,9 @@ module Axlsx
# @param [String] str The string the serialized content will be appended to.
# @return [String]
def string(cell, str='')
- if cell.is_formula?
+ if cell.is_array_formula?
+ array_formula_serialization cell, str
+ elsif cell.is_formula?
formula_serialization cell, str
elsif !cell.ssti.nil?
value_serialization 's', cell.ssti, str