Skip to content

Commit

Permalink
This closes qax-os#1560, fix incorrect row number when get object pos…
Browse files Browse the repository at this point in the history
…ition
  • Loading branch information
xuri committed Jun 11, 2023
1 parent 5d45f41 commit 45e6695
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions col.go
Original file line number Diff line number Diff line change
Expand Up @@ -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++
}

Expand Down
2 changes: 1 addition & 1 deletion picture_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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())
}
Expand Down

0 comments on commit 45e6695

Please sign in to comment.