Fix the issue caused by missing tradition to strict conversion for `sharedStringsReader()`, relate issue #276

This commit is contained in:
xuri 2018-10-18 10:23:08 +08:00
parent 1c45425f12
commit 90bdd3632f
No known key found for this signature in database
GPG Key ID: BA5E5BB1C948EDF7
3 changed files with 3 additions and 7 deletions

View File

@ -182,7 +182,7 @@ func (f *File) addDrawingVML(commentID int, drawingVML, cell string, lineCount,
c, ok := f.XLSX[drawingVML] c, ok := f.XLSX[drawingVML]
if ok { if ok {
d := decodeVmlDrawing{} d := decodeVmlDrawing{}
_ = xml.Unmarshal([]byte(c), &d) _ = xml.Unmarshal(namespaceStrictToTransitional(c), &d)
for _, v := range d.Shape { for _, v := range d.Shape {
s := xlsxShape{ s := xlsxShape{
ID: "_x0000_s1025", ID: "_x0000_s1025",
@ -252,7 +252,7 @@ func (f *File) addComment(commentsXML, cell string, formatSet *formatComment) {
c, ok := f.XLSX[commentsXML] c, ok := f.XLSX[commentsXML]
if ok { if ok {
d := xlsxComments{} d := xlsxComments{}
_ = xml.Unmarshal([]byte(c), &d) _ = xml.Unmarshal(namespaceStrictToTransitional(c), &d)
comments.CommentList.Comment = append(comments.CommentList.Comment, d.CommentList.Comment...) comments.CommentList.Comment = append(comments.CommentList.Comment, d.CommentList.Comment...)
} }
comments.CommentList.Comment = append(comments.CommentList.Comment, cmt) comments.CommentList.Comment = append(comments.CommentList.Comment, cmt)

View File

@ -135,10 +135,6 @@ func TestOpenFile(t *testing.T) {
if err != nil { if err != nil {
t.Log(err) t.Log(err)
} }
_, err = xlsx.WriteToBuffer()
if err != nil {
t.Error(err)
}
} }
func TestAddPicture(t *testing.T) { func TestAddPicture(t *testing.T) {

View File

@ -249,7 +249,7 @@ func (f *File) sharedStringsReader() *xlsxSST {
if len(ss) == 0 { if len(ss) == 0 {
ss = f.readXML("xl/SharedStrings.xml") ss = f.readXML("xl/SharedStrings.xml")
} }
_ = xml.Unmarshal([]byte(ss), &sharedStrings) _ = xml.Unmarshal(namespaceStrictToTransitional(ss), &sharedStrings)
f.SharedStrings = &sharedStrings f.SharedStrings = &sharedStrings
} }
return f.SharedStrings return f.SharedStrings