From 544ef18a8cb9949fcb8833c6d2816783c90f3318 Mon Sep 17 00:00:00 2001 From: xuri Date: Mon, 5 Jul 2021 00:03:56 +0800 Subject: - Support concurrency iterate rows and columns - Rename exported field `File.XLSX` to `File.Pkg` - Exported error message --- comment.go | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) (limited to 'comment.go') diff --git a/comment.go b/comment.go index b05f308..306826d 100644 --- a/comment.go +++ b/comment.go @@ -299,11 +299,12 @@ func (f *File) addComment(commentsXML, cell string, formatSet *formatComment) { // the folder xl. func (f *File) countComments() int { c1, c2 := 0, 0 - for k := range f.XLSX { - if strings.Contains(k, "xl/comments") { + f.Pkg.Range(func(k, v interface{}) bool { + if strings.Contains(k.(string), "xl/comments") { c1++ } - } + return true + }) for rel := range f.Comments { if strings.Contains(rel, "xl/comments") { c2++ @@ -321,10 +322,10 @@ func (f *File) decodeVMLDrawingReader(path string) *decodeVmlDrawing { var err error if f.DecodeVMLDrawing[path] == nil { - c, ok := f.XLSX[path] - if ok { + c, ok := f.Pkg.Load(path) + if ok && c != nil { f.DecodeVMLDrawing[path] = new(decodeVmlDrawing) - if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(c))). + if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(c.([]byte)))). Decode(f.DecodeVMLDrawing[path]); err != nil && err != io.EOF { log.Printf("xml decode error: %s", err) } @@ -339,7 +340,7 @@ func (f *File) vmlDrawingWriter() { for path, vml := range f.VMLDrawing { if vml != nil { v, _ := xml.Marshal(vml) - f.XLSX[path] = v + f.Pkg.Store(path, v) } } } @@ -348,12 +349,11 @@ func (f *File) vmlDrawingWriter() { // after deserialization of xl/comments%d.xml. func (f *File) commentsReader(path string) *xlsxComments { var err error - if f.Comments[path] == nil { - content, ok := f.XLSX[path] - if ok { + content, ok := f.Pkg.Load(path) + if ok && content != nil { f.Comments[path] = new(xlsxComments) - if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(content))). + if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(content.([]byte)))). Decode(f.Comments[path]); err != nil && err != io.EOF { log.Printf("xml decode error: %s", err) } -- cgit v1.2.1