summaryrefslogtreecommitdiff
path: root/chart.go
diff options
context:
space:
mode:
authorAlex Geer <monoflash@gmail.com>2019-12-19 19:30:48 +0300
committerxuri <xuri.me@gmail.com>2019-12-20 00:30:48 +0800
commitb1b3c0d15158abc71267da5893de020f047c3872 (patch)
tree53f9e5a1f42130825572a3c3eea39b2eb4d00f62 /chart.go
parenta00ba75f0f294ce04bfe8d25703d13cd27d6284f (diff)
Fix #539 Fixed error opening excel file created in encoding d… (#540)
* Fixed issue #539 Fixed error opening excel file created in encoding different from UTF-8, added logging of possible errors when decoding XML if the function does not provide exit with an error * Added test for CharsetReader * Fixed #discussion_r359397878 Discussion: https://github.com/360EntSecGroup-Skylar/excelize/pull/540#discussion_r359397878 * Fixed go fmt * go mod tidy and removed unused imports * The code has been refactored
Diffstat (limited to 'chart.go')
-rw-r--r--chart.go16
1 files changed, 13 insertions, 3 deletions
diff --git a/chart.go b/chart.go
index 7d40405..aaa7cd6 100644
--- a/chart.go
+++ b/chart.go
@@ -10,9 +10,12 @@
package excelize
import (
+ "bytes"
"encoding/json"
"encoding/xml"
"errors"
+ "io"
+ "log"
"strconv"
"strings"
)
@@ -1735,14 +1738,21 @@ func (f *File) drawPlotAreaTxPr() *cTxPr {
// deserialization, two different structures: decodeWsDr and encodeWsDr are
// defined.
func (f *File) drawingParser(path string) (*xlsxWsDr, int) {
+ var (
+ err error
+ ok bool
+ )
+
if f.Drawings[path] == nil {
content := xlsxWsDr{}
content.A = NameSpaceDrawingML
content.Xdr = NameSpaceDrawingMLSpreadSheet
- _, ok := f.XLSX[path]
- if ok { // Append Model
+ if _, ok = f.XLSX[path]; ok { // Append Model
decodeWsDr := decodeWsDr{}
- _ = xml.Unmarshal(namespaceStrictToTransitional(f.readXML(path)), &decodeWsDr)
+ if err = f.xmlNewDecoder(bytes.NewReader(namespaceStrictToTransitional(f.readXML(path)))).
+ Decode(&decodeWsDr); err != nil && err != io.EOF {
+ log.Printf("xml decode error: %s", err)
+ }
content.R = decodeWsDr.R
for _, v := range decodeWsDr.OneCellAnchor {
content.OneCellAnchor = append(content.OneCellAnchor, &xdrCellAnchor{