diff options
| author | Paul Kmiec <[email protected]> | 2023-05-14 20:01:22 -0700 |
|---|---|---|
| committer | Paul Kmiec <[email protected]> | 2023-05-15 13:55:04 -0700 |
| commit | 57865b2f08ae301f4d6815211fba59fefafcec33 (patch) | |
| tree | 60510659a8b9cb9409ce8e52e99b1f5bd05c5259 | |
| parent | 71b358f0c73c73f88275b4c1c89fdf5372281ada (diff) | |
| download | caxlsx-57865b2f08ae301f4d6815211fba59fefafcec33.tar.gz caxlsx-57865b2f08ae301f4d6815211fba59fefafcec33.zip | |
Also cache row_ref
The `row_ref` method is called once for each column in a row and once at the
row level.
| -rw-r--r-- | lib/axlsx.rb | 4 | ||||
| -rw-r--r-- | lib/axlsx/workbook/worksheet/row.rb | 2 |
2 files changed, 3 insertions, 3 deletions
diff --git a/lib/axlsx.rb b/lib/axlsx.rb index 30683458..bf16afbd 100644 --- a/lib/axlsx.rb +++ b/lib/axlsx.rb @@ -125,7 +125,6 @@ module Axlsx end chars.prepend((i + 65).chr) chars.freeze - chars end end @@ -133,7 +132,8 @@ module Axlsx # @note The spreadsheet rows are 1-based and the passed in index is 0-based, so we add 1. # @return [String] def self.row_ref(index) - (index + 1).to_s + @row_ref ||= {} + @row_ref[index] ||= (index + 1).to_s.freeze end # @return [String] The alpha(column)numeric(row) reference for this sell. diff --git a/lib/axlsx/workbook/worksheet/row.rb b/lib/axlsx/workbook/worksheet/row.rb index 16116835..dc0320b7 100644 --- a/lib/axlsx/workbook/worksheet/row.rb +++ b/lib/axlsx/workbook/worksheet/row.rb @@ -89,7 +89,7 @@ module Axlsx # @param [String] str The string this rows xml will be appended to. # @return [String] def to_xml_string(r_index, str = +'') - serialized_tag('row', str, :r => r_index + 1) do + serialized_tag('row', str, :r => Axlsx.row_ref(r_index)) do each_with_index { |cell, c_index| cell.to_xml_string(r_index, c_index, str) } end end |
