diff options
author | Ri Xu <xuri.me@gmail.com> | 2017-04-01 13:56:39 +0800 |
---|---|---|
committer | Ri Xu <xuri.me@gmail.com> | 2017-04-01 13:56:39 +0800 |
commit | 8fd061b98f660f5b67380bda13a5424f3a8164c1 (patch) | |
tree | 4dc8e555f2a95c489c3d8cb912fa0b2952c2422a /picture.go | |
parent | 330c7a0925353c8458747b309ad94067beae1d34 (diff) |
- Fix SheetCount count error;
- Optimize deserialization operations;
- README updated, add go version required notice
Diffstat (limited to 'picture.go')
-rw-r--r-- | picture.go | 12 |
1 files changed, 2 insertions, 10 deletions
@@ -303,8 +303,7 @@ func (f *File) addMedia(file string, ext string) { // for relationship parts and the Main Document part. func (f *File) setContentTypePartImageExtensions() { var imageTypes = map[string]bool{"jpeg": false, "png": false, "gif": false} - var content xlsxTypes - xml.Unmarshal([]byte(f.readXML("[Content_Types].xml")), &content) + content := f.contentTypesReader() for _, v := range content.Defaults { _, ok := imageTypes[v.Extension] if ok { @@ -319,8 +318,6 @@ func (f *File) setContentTypePartImageExtensions() { }) } } - output, _ := xml.Marshal(content) - f.saveFileList("[Content_Types].xml", string(output)) } // addDrawingContentTypePart provides function to add image part relationships @@ -328,12 +325,9 @@ func (f *File) setContentTypePartImageExtensions() { // appropriate content type. func (f *File) addDrawingContentTypePart(index int) { f.setContentTypePartImageExtensions() - var content xlsxTypes - xml.Unmarshal([]byte(f.readXML("[Content_Types].xml")), &content) + content := f.contentTypesReader() for _, v := range content.Overrides { if v.PartName == "/xl/drawings/drawing"+strconv.Itoa(index)+".xml" { - output, _ := xml.Marshal(content) - f.saveFileList(`[Content_Types].xml`, string(output)) return } } @@ -341,8 +335,6 @@ func (f *File) addDrawingContentTypePart(index int) { PartName: "/xl/drawings/drawing" + strconv.Itoa(index) + ".xml", ContentType: "application/vnd.openxmlformats-officedocument.drawing+xml", }) - output, _ := xml.Marshal(content) - f.saveFileList("[Content_Types].xml", string(output)) } // getSheetRelationshipsTargetByID provides function to get Target attribute |