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

Picture counting problem #1404

Closed
starmilkxin opened this issue Nov 27, 2022 · 2 comments
Closed

Picture counting problem #1404

starmilkxin opened this issue Nov 27, 2022 · 2 comments
Labels
bug Something isn't working

Comments

@starmilkxin
Copy link

starmilkxin commented Nov 27, 2022

Description

Picture counting problem makes two sheets have the same picture.

Steps to reproduce the issue:

func TestDeletePictureBug(t *testing.T) {
	f, err := excelize.OpenFile(filepath.Join("test", "Book1.xlsx"))
	assert.NoError(t, err)
	// f.countDrawings = 1, pkg: drawing1.xml, drawings: nil
	assert.NoError(t, f.DeletePicture("Sheet1", "A1"))
	// f.countDrawings = 2, pkg: (drawing1.xml, sheet1), drawings: (drawing1.xml, sheet1)
	f.NewSheet("Sheet3")
	assert.NoError(t, f.AddPicture("Sheet3", "P1", filepath.Join("test", "images", "excel.jpg"), ""))
	// f.countDrawings = 3, pkg: (drawing1.xml, sheet1), drawings: (drawing1.xml, sheet1), (drawing3.xml, sheet3)
	assert.NoError(t, f.AddPicture("Sheet2", "P1", filepath.Join("test", "images", "excel.jpg"), ""))
	// f.countDrawings = 4, pkg: (drawing1.xml, sheet1), drawings: (drawing1.xml, sheet1), (drawing3.xml, sheet3), (drawing4.xml, sheet2)
	assert.NoError(t, f.DeletePicture("Sheet2", "P1"))
	f.DeleteSheet("Sheet1")
	assert.NoError(t, f.SaveAs(filepath.Join("test", "TestDeletePicture1.xlsx")))
	f, err = excelize.OpenFile(filepath.Join("test", "TestDeletePicture1.xlsx"))
	assert.NoError(t, err)
	// f.countDrawings = 3, pkg: (drawing1.xml, sheet1),(drawing3.xml, sheet3), (drawing4.xml, sheet2), drawings: nil
	f.NewSheet("Sheet1")
	assert.NoError(t, f.AddPicture("Sheet1", "H1", filepath.Join("test", "images", "pic.jpg"), `{"x_scale": 0.5, "y_scale": 0.5}`))
	// f.countDrawings = 4, pkg: (drawing1.xml, sheet1),(drawing3.xml, sheet3), (drawing4.xml, sheet2), drawings: (drawing4.xml, sheet1)
	assert.NoError(t, f.SaveAs(filepath.Join("test", "TestDeletePicture2.xlsx")))
	// sheet1 and sheet2 all have pic.jpg !
}

Describe the results you received:
sheet1 and sheet2 all have pic.jpg

Describe the results you expected:
only sheet2 has pic.jpg

Output of go version:

go1.18.3 windows/amd64

Excelize version or commit ID:

v2.6.1

Environment details (OS, Microsoft Excel™ version, physical, etc.):

@starmilkxin
Copy link
Author

Book1.xlsx and excel.jpg are under excelize's path "test" and "test/images"

@xuri xuri added bug Something isn't working in progress Working in progress labels Nov 27, 2022
@xuri xuri closed this as completed in c071395 Nov 28, 2022
@xuri
Copy link
Member

xuri commented Nov 29, 2022

Thanks for your feedback. I have made a fix for this issue, please upgrade to the master branch code.

@xuri xuri removed the in progress Working in progress label Nov 29, 2022
xuri added a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
- Updates unit tests
- Updates documentation for stream mode functions
- Updates hyperlinks in the documentation
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
- Updates unit tests
- Updates documentation for stream mode functions
- Updates hyperlinks in the documentation
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