@@ -497,8 +497,7 @@ func (f *File) GetPictures(sheet, cell string) ([]Picture, error) {
497
497
target := f .getSheetRelationshipsTargetByID (sheet , ws .Drawing .RID )
498
498
drawingXML := strings .TrimPrefix (strings .ReplaceAll (target , ".." , "xl" ), "/" )
499
499
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" )
502
501
imgs , err := f .getCellImages (sheet , cell )
503
502
if err != nil {
504
503
return nil , err
@@ -526,7 +525,8 @@ func (f *File) GetPictureCells(sheet string) ([]string, error) {
526
525
target := f .getSheetRelationshipsTargetByID (sheet , ws .Drawing .RID )
527
526
drawingXML := strings .TrimPrefix (strings .ReplaceAll (target , ".." , "xl" ), "/" )
528
527
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
+
530
530
embeddedImageCells , err := f .getImageCells (sheet )
531
531
if err != nil {
532
532
return nil , err
@@ -609,8 +609,15 @@ func (f *File) getPicture(row, col int, drawingXML, drawingRelationships string)
609
609
}
610
610
}
611
611
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 {
614
621
pic .File = buffer .([]byte )
615
622
pic .Format .AltText = a .Pic .NvPicPr .CNvPr .Descr
616
623
pics = append (pics , pic )
@@ -770,7 +777,14 @@ func (f *File) getPictureCells(drawingXML, drawingRelationships string) ([]strin
770
777
}
771
778
}
772
779
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 {
774
788
if cell , err := CoordinatesToCellName (a .From .Col + 1 , a .From .Row + 1 ); err == nil && inStrSlice (cells , cell , true ) == - 1 {
775
789
cells = append (cells , cell )
776
790
}
0 commit comments