summaryrefslogtreecommitdiff
path: root/lib.go
diff options
context:
space:
mode:
authorRi Xu <xuri.me@gmail.com>2017-09-06 12:16:39 +0800
committerGitHub <noreply@github.com>2017-09-06 12:16:39 +0800
commit1f93fc7bad0f1a4cd7f3b037a0f370561eae83b1 (patch)
tree9307fb93ce9fb7ee54b8c44595da605976511f53 /lib.go
parent363604e2f3775a5cef24eff73ef7e5ab3f7e2587 (diff)
Optimize code.
Diffstat (limited to 'lib.go')
-rw-r--r--lib.go8
1 files changed, 3 insertions, 5 deletions
diff --git a/lib.go b/lib.go
index ab83e50..b28b50f 100644
--- a/lib.go
+++ b/lib.go
@@ -70,8 +70,8 @@ func ToAlphaString(value int) string {
}
// TitleToNumber provides function to convert Excel sheet column title to int
-// (this function doesn't do value check currently). For example convert AK(ak、Ak) to
-// column title 36:
+// (this function doesn't do value check currently). For example convert AK
+// and ak to column title 36:
//
// excelize.TitleToNumber("AK")
// excelize.TitleToNumber("ak")
@@ -80,11 +80,9 @@ func TitleToNumber(s string) int {
weight := 0.0
sum := 0
for i := len(s) - 1; i >= 0; i-- {
- var ch int
+ ch := int(s[i])
if int(s[i]) >= int('a') && int(s[i]) <= int('z') {
ch = int(s[i]) - 32
- } else {
- ch = int(s[i])
}
sum = sum + (ch-int('A')+1)*int(math.Pow(26, weight))
weight++