From 8e891b52c65de3445abdd094204904e0c1b32ea3 Mon Sep 17 00:00:00 2001 From: xuri Date: Mon, 12 Jun 2023 00:09:40 +0800 Subject: [PATCH] This closes #1560, fix incorrect row number when get object position --- col.go | 8 ++++---- picture_test.go | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/col.go b/col.go index 4d19a2aa..bbb5d298 100644 --- a/col.go +++ b/col.go @@ -605,14 +605,14 @@ func flatCols(col xlsxCol, cols []xlsxCol, replacer func(fc, c xlsxCol) xlsxCol) // height # Height of object frame. func (f *File) positionObjectPixels(sheet string, col, row, x1, y1, width, height int) (int, int, int, int, int, int) { // Adjust start column for offsets that are greater than the col width. - for x1 >= f.getColWidth(sheet, col) { - x1 -= f.getColWidth(sheet, col) + for x1 >= f.getColWidth(sheet, col+1) { + x1 -= f.getColWidth(sheet, col+1) col++ } // Adjust start row for offsets that are greater than the row height. - for y1 >= f.getRowHeight(sheet, row) { - y1 -= f.getRowHeight(sheet, row) + for y1 >= f.getRowHeight(sheet, row+1) { + y1 -= f.getRowHeight(sheet, row+1) row++ } diff --git a/picture_test.go b/picture_test.go index 95bb39e9..54f9bb0c 100644 --- a/picture_test.go +++ b/picture_test.go @@ -108,7 +108,7 @@ func TestAddPictureErrors(t *testing.T) { assert.NoError(t, f.AddPicture("Sheet1", "Q7", filepath.Join("test", "images", "excel.wmf"), nil)) assert.NoError(t, f.AddPicture("Sheet1", "Q13", filepath.Join("test", "images", "excel.emz"), nil)) assert.NoError(t, f.AddPicture("Sheet1", "Q19", filepath.Join("test", "images", "excel.wmz"), nil)) - assert.NoError(t, f.AddPicture("Sheet1", "Q25", "excelize.svg", &GraphicOptions{ScaleX: 2.1})) + assert.NoError(t, f.AddPicture("Sheet1", "Q25", "excelize.svg", &GraphicOptions{ScaleX: 2.8})) assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddPicture2.xlsx"))) assert.NoError(t, f.Close()) }