@@ -135,7 +135,23 @@ func (f *File) addSheetDrawing(sheet string, rID int) {
135135 if err != nil {
136136 fmt .Println (err )
137137 }
138- f .saveFileList (name , string (output ))
138+ f .saveFileList (name , replaceWorkSheetsRelationshipsNameSpace (string (output )))
139+ }
140+
141+ // addSheetPicture provides function to add picture element to
142+ // xl/worksheets/sheet%d.xml by given sheet name and relationship index.
143+ func (f * File ) addSheetPicture (sheet string , rID int ) {
144+ var xlsx xlsxWorksheet
145+ name := "xl/worksheets/" + strings .ToLower (sheet ) + ".xml"
146+ xml .Unmarshal ([]byte (f .readXML (name )), & xlsx )
147+ xlsx .Picture = & xlsxPicture {
148+ RID : "rId" + strconv .Itoa (rID ),
149+ }
150+ output , err := xml .Marshal (xlsx )
151+ if err != nil {
152+ fmt .Println (err )
153+ }
154+ f .saveFileList (name , replaceWorkSheetsRelationshipsNameSpace (string (output )))
139155}
140156
141157// countDrawings provides function to get drawing files count storage in the
@@ -270,13 +286,10 @@ func (f *File) addMedia(file string, ext string) {
270286 f .XLSX [media ] = string (dat )
271287}
272288
273- // addDrawingContentTypePart provides function to add image part relationships
274- // in http://purl.oclc.org/ooxml/officeDocument/relationships/image and
275- // appropriate content type.
276- func (f * File ) addDrawingContentTypePart (index int ) {
289+ func (f * File ) setContentTypePartImageExtensions () {
277290 var imageTypes = map [string ]bool {"jpeg" : false , "png" : false , "gif" : false }
278291 var content xlsxTypes
279- xml .Unmarshal ([]byte (f .readXML (` [Content_Types].xml` )), & content )
292+ xml .Unmarshal ([]byte (f .readXML (" [Content_Types].xml" )), & content )
280293 for _ , v := range content .Defaults {
281294 _ , ok := imageTypes [v .Extension ]
282295 if ok {
@@ -291,6 +304,17 @@ func (f *File) addDrawingContentTypePart(index int) {
291304 })
292305 }
293306 }
307+ output , _ := xml .Marshal (content )
308+ f .saveFileList ("[Content_Types].xml" , string (output ))
309+ }
310+
311+ // addDrawingContentTypePart provides function to add image part relationships
312+ // in http://purl.oclc.org/ooxml/officeDocument/relationships/image and
313+ // appropriate content type.
314+ func (f * File ) addDrawingContentTypePart (index int ) {
315+ f .setContentTypePartImageExtensions ()
316+ var content xlsxTypes
317+ xml .Unmarshal ([]byte (f .readXML ("[Content_Types].xml" )), & content )
294318 for _ , v := range content .Overrides {
295319 if v .PartName == "/xl/drawings/drawing" + strconv .Itoa (index )+ ".xml" {
296320 output , _ := xml .Marshal (content )
@@ -303,7 +327,7 @@ func (f *File) addDrawingContentTypePart(index int) {
303327 ContentType : "application/vnd.openxmlformats-officedocument.drawing+xml" ,
304328 })
305329 output , _ := xml .Marshal (content )
306- f .saveFileList (` [Content_Types].xml` , string (output ))
330+ f .saveFileList (" [Content_Types].xml" , string (output ))
307331}
308332
309333// getSheetRelationshipsTargetByID provides function to get Target attribute
0 commit comments