Permalink
Browse files

got the range convertz working

  • Loading branch information...
joshbtn committed Sep 12, 2012
1 parent 789e399 commit 5799cc7e965d4e6dc3ec949fcb4b3d656ea0ea2d
Showing with 14 additions and 9 deletions.
  1. +14 −9 src/ExcelFormulaUtilities.js
@@ -666,16 +666,21 @@
}
// Pass in the base 26 string, get back integer
- function fromBase26(strAlphaNumber) {
- var s = 1
- , aMatch = /[a-z]+/gi
- , i = 0;
+ function fromBase26(number) {
+ number = number.toUpperCase();
- if ( aMatch.test(strAlphaNumber) ) {
- s = ( strAlphaNumber.charCodeAt(0) - ("A".charCodeAt(0) - 1) );
- for (; i < strAlphaNumber.length; i++) {
- s *= 26;
- s += (strAlphaNumber.charCodeAt(i) - "A".charCodeAt(0));
+ var s = 0
+ ,i = 1;
+
+ if (
+ number !== null
+ && typeof number !== "undefined"
+ && number.length > 0
+ ) {
+ s = (number.charCodeAt(0) - "A".charCodeAt(0));
+ for (; i < number.length; i++) {
+ s = s === 0 ? 26 : s * 26;
+ s += (number.charCodeAt(i) - ("A".charCodeAt(0) ));
}
}

0 comments on commit 5799cc7

Please sign in to comment.