Skip to content

Commit 8e891b5

Browse files
committed
This closes #1560, fix incorrect row number when get object position
1 parent 78c974d commit 8e891b5

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

col.go

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -605,14 +605,14 @@ func flatCols(col xlsxCol, cols []xlsxCol, replacer func(fc, c xlsxCol) xlsxCol)
605605
// height # Height of object frame.
606606
func (f *File) positionObjectPixels(sheet string, col, row, x1, y1, width, height int) (int, int, int, int, int, int) {
607607
// Adjust start column for offsets that are greater than the col width.
608-
for x1 >= f.getColWidth(sheet, col) {
609-
x1 -= f.getColWidth(sheet, col)
608+
for x1 >= f.getColWidth(sheet, col+1) {
609+
x1 -= f.getColWidth(sheet, col+1)
610610
col++
611611
}
612612

613613
// Adjust start row for offsets that are greater than the row height.
614-
for y1 >= f.getRowHeight(sheet, row) {
615-
y1 -= f.getRowHeight(sheet, row)
614+
for y1 >= f.getRowHeight(sheet, row+1) {
615+
y1 -= f.getRowHeight(sheet, row+1)
616616
row++
617617
}
618618

picture_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ func TestAddPictureErrors(t *testing.T) {
108108
assert.NoError(t, f.AddPicture("Sheet1", "Q7", filepath.Join("test", "images", "excel.wmf"), nil))
109109
assert.NoError(t, f.AddPicture("Sheet1", "Q13", filepath.Join("test", "images", "excel.emz"), nil))
110110
assert.NoError(t, f.AddPicture("Sheet1", "Q19", filepath.Join("test", "images", "excel.wmz"), nil))
111-
assert.NoError(t, f.AddPicture("Sheet1", "Q25", "excelize.svg", &GraphicOptions{ScaleX: 2.1}))
111+
assert.NoError(t, f.AddPicture("Sheet1", "Q25", "excelize.svg", &GraphicOptions{ScaleX: 2.8}))
112112
assert.NoError(t, f.SaveAs(filepath.Join("test", "TestAddPicture2.xlsx")))
113113
assert.NoError(t, f.Close())
114114
}

0 commit comments

Comments
 (0)