From c0713951c8d95fba3a23da39bfb5c85d858d2338 Mon Sep 17 00:00:00 2001 From: xuri Date: Tue, 29 Nov 2022 00:03:49 +0800 Subject: This closes #1404, fixes the insert picture problem in some cases - Updates unit tests - Updates documentation for stream mode functions - Updates hyperlinks in the documentation --- picture.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'picture.go') diff --git a/picture.go b/picture.go index 4e8a652..b4629b0 100644 --- a/picture.go +++ b/picture.go @@ -250,20 +250,24 @@ func (f *File) addSheetPicture(sheet string, rID int) error { // countDrawings provides a function to get drawing files count storage in the // folder xl/drawings. -func (f *File) countDrawings() (count int) { +func (f *File) countDrawings() int { + var c1, c2 int f.Pkg.Range(func(k, v interface{}) bool { if strings.Contains(k.(string), "xl/drawings/drawing") { - count++ + c1++ } return true }) f.Drawings.Range(func(rel, value interface{}) bool { if strings.Contains(rel.(string), "xl/drawings/drawing") { - count++ + c2++ } return true }) - return + if c1 < c2 { + return c2 + } + return c1 } // addDrawingPicture provides a function to add picture by given sheet, -- cgit v1.2.1