summaryrefslogtreecommitdiff
path: root/cell.go
diff options
context:
space:
mode:
authorRi Xu <xuri.me@gmail.com>2017-10-16 10:42:43 +0800
committerRi Xu <xuri.me@gmail.com>2017-10-16 10:42:43 +0800
commit9b5b74d4801f60daa580fd282ff9fa058bb03385 (patch)
tree932febf22a36d6b03095070c98ac94c690ab59ef /cell.go
parent905be463edc6d9b0ed184bdee0116217a5118c5e (diff)
Performance optimization, use the array index instead of the value in range.
Diffstat (limited to 'cell.go')
-rw-r--r--cell.go32
1 files changed, 16 insertions, 16 deletions
diff --git a/cell.go b/cell.go
index c47b1f1..36b8ef9 100644
--- a/cell.go
+++ b/cell.go
@@ -91,11 +91,11 @@ func (f *File) GetCellValue(sheet, axis string) string {
if rows < xAxis {
return ""
}
- for _, v := range xlsx.SheetData.Row {
- if v.R == row {
- for _, r := range v.C {
- if axis == r.R {
- val, _ := r.getValueFrom(f, f.sharedStringsReader())
+ for k := range xlsx.SheetData.Row {
+ if xlsx.SheetData.Row[k].R == row {
+ for i := range xlsx.SheetData.Row[k].C {
+ if axis == xlsx.SheetData.Row[k].C[i].R {
+ val, _ := xlsx.SheetData.Row[k].C[i].getValueFrom(f, f.sharedStringsReader())
return val
}
}
@@ -161,12 +161,12 @@ func (f *File) GetCellFormula(sheet, axis string) string {
if rows < xAxis {
return ""
}
- for _, v := range xlsx.SheetData.Row {
- if v.R == row {
- for _, f := range v.C {
- if axis == f.R {
- if f.F != nil {
- return f.F.Content
+ for k := range xlsx.SheetData.Row {
+ if xlsx.SheetData.Row[k].R == row {
+ for i := range xlsx.SheetData.Row[k].C {
+ if axis == xlsx.SheetData.Row[k].C[i].R {
+ if xlsx.SheetData.Row[k].C[i].F != nil {
+ return xlsx.SheetData.Row[k].C[i].F.Content
}
}
}
@@ -256,12 +256,12 @@ func (f *File) GetCellHyperLink(sheet, axis string) (bool, string) {
if xlsx.Hyperlinks == nil || axis == "" {
return link, target
}
- for _, h := range xlsx.Hyperlinks.Hyperlink {
- if h.Ref == axis {
+ for h := range xlsx.Hyperlinks.Hyperlink {
+ if xlsx.Hyperlinks.Hyperlink[h].Ref == axis {
link = true
- target = h.Location
- if h.RID != "" {
- target = f.getSheetRelationshipsTargetByID(sheet, h.RID)
+ target = xlsx.Hyperlinks.Hyperlink[h].Location
+ if xlsx.Hyperlinks.Hyperlink[h].RID != "" {
+ target = f.getSheetRelationshipsTargetByID(sheet, xlsx.Hyperlinks.Hyperlink[h].RID)
}
}
}