Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AddPicture (autofit) has a size problem when there are multiple merged cells. #748

Closed
yuki2006 opened this issue Dec 14, 2020 · 1 comment
Labels
bug Something isn't working

Comments

@yuki2006
Copy link
Contributor

yuki2006 commented Dec 14, 2020

Thank you for the very useful library.

Description

Depending on the order of the merged cells,
The size of the image changes because the cell merge detection cannot be performed.

Probably the line is wrong and the inMergeCell is overwritten and it is not judged correctly.

https://github.com/360EntSecGroup-Skylar/excelize/blob/master/picture.go#L608

Steps to reproduce the issue:
1.

		f := excelize.NewFile()
		sheet1 := f.GetSheetName(0)

		f.MergeCell(sheet1, "A2", "C3")
		f.MergeCell(sheet1, "A100", "C101")

		err := f.AddPicture(sheet1, "A2", "../../.ignore/Pic.jpg", `{"lock_aspect_ratio":true,"autofit":true}`)
		if err != nil {
			t.Error(err)
			return
		}

		f.SaveAs("/tmp/A.xlsx")

image

		f := excelize.NewFile()
		sheet1 := f.GetSheetName(0)

		f.MergeCell(sheet1, "A100", "C101")
		f.MergeCell(sheet1, "A2", "C3")

		err := f.AddPicture(sheet1, "A2", "../../.ignore/Pic.jpg", `{"lock_aspect_ratio":true,"autofit":true}`)
		if err != nil {
			t.Error(err)
			return
		}

		f.SaveAs("/tmp/B.xlsx")

image

Describe the results you expected:

Display pattern 2 regardless of the order of merged cells.

Output of go version:

go1.15

Excelize version or commit ID:

v2.3.1

@xuri xuri added bug Something isn't working in progress Working in progress labels Dec 14, 2020
@xuri xuri closed this as completed in 77978ac Dec 14, 2020
@xuri xuri removed the in progress Working in progress label Dec 14, 2020
@xuri
Copy link
Member

xuri commented Dec 14, 2020

Hi, @yuki2006. Thanks for your issue. I have fixed it, please try to use the master branch code, and this patch will be released in the next version.

jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
… marker symbol and symbol size, fix AddPicture auto fit failure with multi merged cells
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants