From 6cca8025c28553cd1adbb2a54b43d64685664fb7 Mon Sep 17 00:00:00 2001 From: Jesse Luehrs Date: Thu, 29 Aug 2013 15:29:33 -0400 Subject: fix this algorithm, again (jasonshaev) --- lib/Spreadsheet/Template/Helpers/Xslate.pm | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/Spreadsheet/Template/Helpers/Xslate.pm b/lib/Spreadsheet/Template/Helpers/Xslate.pm index 8712656..56df981 100644 --- a/lib/Spreadsheet/Template/Helpers/Xslate.pm +++ b/lib/Spreadsheet/Template/Helpers/Xslate.pm @@ -3,7 +3,6 @@ use strict; use warnings; use JSON; -use POSIX; my $JSON = JSON->new; @@ -82,13 +81,13 @@ sub _cell_to_row_col { my ($col, $row) = $cell =~ /([A-Z]+)([0-9]+)/; - (my $ncol = $col) =~ tr/A-Z/1-9A-Q/; - $ncol = POSIX::strtol($ncol, 27); - $ncol -= 1; + my $ncol = 0; + for my $char (split //, $col) { + $ncol *= 26; + $ncol += ord($char) - ord('A') + 1; + } - my $nrow = $row - 1; - - return [ $nrow, $ncol ]; + return [ $row - 1, $ncol - 1 ]; } sub _formats { -- cgit v1.2.3-54-g00ecf