@@ -497,8 +497,7 @@ func (f *File) GetPictures(sheet, cell string) ([]Picture, error) {
497497 target := f .getSheetRelationshipsTargetByID (sheet , ws .Drawing .RID )
498498 drawingXML := strings .TrimPrefix (strings .ReplaceAll (target , ".." , "xl" ), "/" )
499499 drawingRelationships := strings .ReplaceAll (
500- strings .ReplaceAll (target , "../drawings" , "xl/drawings/_rels" ), ".xml" , ".xml.rels" )
501-
500+ strings .ReplaceAll (drawingXML , "xl/drawings" , "xl/drawings/_rels" ), ".xml" , ".xml.rels" )
502501 imgs , err := f .getCellImages (sheet , cell )
503502 if err != nil {
504503 return nil , err
@@ -526,7 +525,8 @@ func (f *File) GetPictureCells(sheet string) ([]string, error) {
526525 target := f .getSheetRelationshipsTargetByID (sheet , ws .Drawing .RID )
527526 drawingXML := strings .TrimPrefix (strings .ReplaceAll (target , ".." , "xl" ), "/" )
528527 drawingRelationships := strings .ReplaceAll (
529- strings .ReplaceAll (target , "../drawings" , "xl/drawings/_rels" ), ".xml" , ".xml.rels" )
528+ strings .ReplaceAll (drawingXML , "xl/drawings" , "xl/drawings/_rels" ), ".xml" , ".xml.rels" )
529+
530530 embeddedImageCells , err := f .getImageCells (sheet )
531531 if err != nil {
532532 return nil , err
@@ -609,8 +609,15 @@ func (f *File) getPicture(row, col int, drawingXML, drawingRelationships string)
609609 }
610610 }
611611 cb2 := func (a * decodeCellAnchor , r * xlsxRelationship ) {
612- pic := Picture {Extension : filepath .Ext (r .Target ), Format : & GraphicOptions {}, InsertType : PictureInsertTypePlaceOverCells }
613- if buffer , _ := f .Pkg .Load (filepath .ToSlash (filepath .Clean ("xl/drawings/" + r .Target ))); buffer != nil {
612+ var target string
613+ if strings .HasPrefix (r .Target , "/" ) {
614+ target = strings .TrimPrefix (r .Target , "/" )
615+ } else {
616+ target = filepath .ToSlash (filepath .Clean ("xl/drawings/" + r .Target ))
617+ }
618+
619+ pic := Picture {Extension : filepath .Ext (target ), Format : & GraphicOptions {}, InsertType : PictureInsertTypePlaceOverCells }
620+ if buffer , _ := f .Pkg .Load (target ); buffer != nil {
614621 pic .File = buffer .([]byte )
615622 pic .Format .AltText = a .Pic .NvPicPr .CNvPr .Descr
616623 pics = append (pics , pic )
@@ -770,7 +777,14 @@ func (f *File) getPictureCells(drawingXML, drawingRelationships string) ([]strin
770777 }
771778 }
772779 cb2 := func (a * decodeCellAnchor , r * xlsxRelationship ) {
773- if _ , ok := f .Pkg .Load (filepath .ToSlash (filepath .Clean ("xl/drawings/" + r .Target ))); ok {
780+ var target string
781+ if strings .HasPrefix (r .Target , "/" ) {
782+ target = strings .TrimPrefix (r .Target , "/" )
783+ } else {
784+ target = filepath .ToSlash (filepath .Clean ("xl/drawings/" + r .Target ))
785+ }
786+
787+ if _ , ok := f .Pkg .Load (target ); ok {
774788 if cell , err := CoordinatesToCellName (a .From .Col + 1 , a .From .Row + 1 ); err == nil && inStrSlice (cells , cell , true ) == - 1 {
775789 cells = append (cells , cell )
776790 }
0 commit comments