summaryrefslogtreecommitdiff
path: root/cell.go
diff options
context:
space:
mode:
authorRi Xu <xuri.me@gmail.com>2017-02-12 19:03:24 +0800
committerRi Xu <xuri.me@gmail.com>2017-02-12 19:03:24 +0800
commit0833a9d5dab846ed01be52fa59c97ede36ee4a93 (patch)
tree9daaf8583f716a924aeb108b7255808d811f3e8c /cell.go
parent53564cbe57522467a7e0febd0c9ae4374fa90808 (diff)
- Improved performance when reading large files, call Token to read tokens one by one instead Unmarshal. Related issue #20 ;
- Fix go test typo; - Update README
Diffstat (limited to 'cell.go')
-rw-r--r--cell.go24
1 files changed, 24 insertions, 0 deletions
diff --git a/cell.go b/cell.go
index e9933aa..3e11298 100644
--- a/cell.go
+++ b/cell.go
@@ -106,6 +106,14 @@ func (f *File) SetCellFormula(sheet, axis, formula string) {
var xlsx xlsxWorksheet
name := "xl/worksheets/" + strings.ToLower(sheet) + ".xml"
xml.Unmarshal([]byte(f.readXML(name)), &xlsx)
+ if f.checked == nil {
+ f.checked = make(map[string]bool)
+ }
+ ok := f.checked[name]
+ if !ok {
+ xlsx = checkRow(xlsx)
+ f.checked[name] = true
+ }
if xlsx.MergeCells != nil {
for i := 0; i < len(xlsx.MergeCells.Cells); i++ {
if checkCellInArea(axis, xlsx.MergeCells.Cells[i].Ref) {
@@ -143,6 +151,14 @@ func (f *File) SetCellHyperLink(sheet, axis, link string) {
var xlsx xlsxWorksheet
name := "xl/worksheets/" + strings.ToLower(sheet) + ".xml"
xml.Unmarshal([]byte(f.readXML(name)), &xlsx)
+ if f.checked == nil {
+ f.checked = make(map[string]bool)
+ }
+ ok := f.checked[name]
+ if !ok {
+ xlsx = checkRow(xlsx)
+ f.checked[name] = true
+ }
if xlsx.MergeCells != nil {
for i := 0; i < len(xlsx.MergeCells.Cells); i++ {
if checkCellInArea(axis, xlsx.MergeCells.Cells[i].Ref) {
@@ -205,6 +221,14 @@ func (f *File) MergeCell(sheet, hcell, vcell string) {
var xlsx xlsxWorksheet
name := "xl/worksheets/" + strings.ToLower(sheet) + ".xml"
xml.Unmarshal([]byte(f.readXML(name)), &xlsx)
+ if f.checked == nil {
+ f.checked = make(map[string]bool)
+ }
+ ok := f.checked[name]
+ if !ok {
+ xlsx = checkRow(xlsx)
+ f.checked[name] = true
+ }
if xlsx.MergeCells != nil {
mergeCell := xlsxMergeCell{}
// Correct the coordinate area, such correct C1:B3 to B1:C3.