diff options
| author | Zsolt Kozaroczy <[email protected]> | 2023-05-31 09:13:56 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-05-31 09:13:56 +0200 |
| commit | 317383fc66da3f04d438c86afb5b639b62145408 (patch) | |
| tree | c8cf180de1775f89f006794d8ce99a28ddf9a714 /lib/axlsx | |
| parent | e1fafb27991eb1bc9050609ab1c0cd24702b8285 (diff) | |
| parent | 171f4ad7d68f8b9e93fa9e65b31bf313d8c57296 (diff) | |
| download | caxlsx-317383fc66da3f04d438c86afb5b639b62145408.tar.gz caxlsx-317383fc66da3f04d438c86afb5b639b62145408.zip | |
Merge pull request #264 from tagliala/chore/improve-cell-reference
Improve absolute cell reference method
Diffstat (limited to 'lib/axlsx')
| -rw-r--r-- | lib/axlsx/workbook/worksheet/cell.rb | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/lib/axlsx/workbook/worksheet/cell.rb b/lib/axlsx/workbook/worksheet/cell.rb index 09cf2064..b4f826c2 100644 --- a/lib/axlsx/workbook/worksheet/cell.rb +++ b/lib/axlsx/workbook/worksheet/cell.rb @@ -73,6 +73,9 @@ module Axlsx CELL_TYPES = [:date, :time, :float, :integer, :richtext, :string, :boolean, :iso_8601, :text].freeze + # A regular expression to match the alpha(column)numeric(row) reference of a cell + CELL_REFERENCE_REGEX = /([A-Z]+)([0-9]+)/.freeze + # The index of the cellXfs item to be applied to this cell. # @return [Integer] # @see Axlsx::Styles @@ -345,11 +348,11 @@ module Axlsx Axlsx::cell_r index, @row.row_index end - # @return [String] The absolute alpha(column)numeric(row) reference for this sell. + # @return [String] The absolute alpha(column)numeric(row) reference for this cell. # @example Absolute Cell Reference # ws.rows.first.cells.first.r #=> "$A$1" def r_abs - "$#{r.match(/([A-Z]+)([0-9]+)/)[1, 2].join('$')}" + "$#{CELL_REFERENCE_REGEX.match(r)[1, 2].join('$')}" end # @return [Integer] The cellXfs item index applied to this cell. |
