diff options
author | xuri <xuri.me@gmail.com> | 2020-01-22 01:08:18 +0800 |
---|---|---|
committer | xuri <xuri.me@gmail.com> | 2020-01-22 01:08:18 +0800 |
commit | cbc3fd21b79fbb819c1c341fc825701c04a0b473 (patch) | |
tree | e92c0c9e2d84bb59911a131d75b61a77cb0e6f83 /picture.go | |
parent | e2bd08c9111b0141c66adf232edb2fd729afa63f (diff) |
Resolve #455, init delete picture from spreadsheet support
Diffstat (limited to 'picture.go')
-rw-r--r-- | picture.go | 21 |
1 files changed, 21 insertions, 0 deletions
@@ -462,6 +462,27 @@ func (f *File) GetPicture(sheet, cell string) (string, []byte, error) { return f.getPicture(row, col, drawingXML, drawingRelationships) } +// DeletePicture provides a function to delete chart in XLSX by given +// worksheet and cell name. Note that the image file won't deleted from the +// document currently. +func (f *File) DeletePicture(sheet, cell string) (err error) { + col, row, err := CellNameToCoordinates(cell) + if err != nil { + return + } + col-- + row-- + ws, err := f.workSheetReader(sheet) + if err != nil { + return + } + if ws.Drawing == nil { + return + } + drawingXML := strings.Replace(f.getSheetRelationshipsTargetByID(sheet, ws.Drawing.RID), "..", "xl", -1) + return f.deleteDrawing(col, row, drawingXML, "Pic") +} + // getPicture provides a function to get picture base name and raw content // embed in XLSX by given coordinates and drawing relationships. func (f *File) getPicture(row, col int, drawingXML, drawingRelationships string) (ret string, buf []byte, err error) { |