summaryrefslogtreecommitdiffhomepage
path: root/lib/axlsx
diff options
context:
space:
mode:
authorZsolt Kozaroczy <[email protected]>2023-05-22 10:38:49 +0200
committerGitHub <[email protected]>2023-05-22 10:38:49 +0200
commit6752225bbb8a9eec905ec02a98f1a25a309c404a (patch)
tree452abd7854a77d57805535c52e7abeaba5e0a573 /lib/axlsx
parent6ae97de9c2bb45631d4d3de9ba890510e70623fb (diff)
parent6909ffbacf9dbfe7bfb01712ca7c47a3ca882dac (diff)
downloadcaxlsx-6752225bbb8a9eec905ec02a98f1a25a309c404a.tar.gz
caxlsx-6752225bbb8a9eec905ec02a98f1a25a309c404a.zip
Merge pull request #236 from pkmiec/smallPerfTweaks
Add `Cell#style_str` so that we can directly return '0'
Diffstat (limited to 'lib/axlsx')
-rw-r--r--lib/axlsx/workbook/worksheet/cell.rb5
-rw-r--r--lib/axlsx/workbook/worksheet/cell_serializer.rb2
2 files changed, 6 insertions, 1 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb
index c978bde4..49afa485 100644
--- a/lib/axlsx/workbook/worksheet/cell.rb
+++ b/lib/axlsx/workbook/worksheet/cell.rb
@@ -80,6 +80,11 @@ module Axlsx
defined?(@style) ? @style : 0
end
+ # Internal
+ def style_str
+ defined?(@style) ? @style.to_s : '0'
+ end
+
attr_accessor :raw_style
# The index of the cellXfs item to be applied to this cell.
diff --git a/lib/axlsx/workbook/worksheet/cell_serializer.rb b/lib/axlsx/workbook/worksheet/cell_serializer.rb
index dceca7eb..30a2b5fe 100644
--- a/lib/axlsx/workbook/worksheet/cell_serializer.rb
+++ b/lib/axlsx/workbook/worksheet/cell_serializer.rb
@@ -12,7 +12,7 @@ module Axlsx
def to_xml_string(row_index, column_index, cell, str = +'')
str << '<c r="'
str << Axlsx::col_ref(column_index) << Axlsx::row_ref(row_index)
- str << '" s="' << cell.style.to_s << '" '
+ str << '" s="' << cell.style_str << '" '
return str << '/>' if cell.value.nil?
method = cell.type