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

Images are duplicated #1017

Closed
ipopa opened this issue Sep 10, 2021 · 2 comments
Closed

Images are duplicated #1017

ipopa opened this issue Sep 10, 2021 · 2 comments
Labels
bug Something isn't working

Comments

@ipopa
Copy link

ipopa commented Sep 10, 2021

Description

We currently have an excel file containing 3 sheets. When adding an image in the sheet 2 and another image in the sheet 3, we have a duplication of this image when saving this file: both of the images are in both sheet 2 and sheet 3.
By removing sheet 1, the issue doesn’t occur anymore, but the thing is we cannot remove it. We guess something is wrong with this first sheet that we want to identify.

Steps to reproduce the issue:

package main

import (
	"testing"

	"github.com/stretchr/testify/assert"
	"github.com/xuri/excelize/v2"
)

func TestAddPicture(t *testing.T) {
	xlsx, err := excelize.OpenFile("./test.xlsx")

	assert.Nil(t, err)

	xlsx.AddPicture("sheet2", "B3", "./image1.png", "{}")
	xlsx.AddPicture("sheet3", "L1", "./image2.png", "{}")

	xlsx.SaveAs("./test_output.xlsx")
}

Describe the results you received:
output preview:
output preview

excel:
test.xlsx

output excel:
test_output.xlsx

images:
image1
image2

Describe the results you expected:
Each image should be added in the sheet it belongs to: Image 1 in sheet 2 and image 2 in sheet 3

Output of go version:

1.16

Excelize version or commit ID:

2.4.1

Environment details (OS, Microsoft Excel™ version, physical, etc.):
OS: macOS Big Sur 11.5.2
Microsoft Excel™ version: Microsoft Excel for Mac 16.52

@xuri xuri added the bug Something isn't working label Sep 10, 2021
@xuri xuri closed this as completed in 52609ba Sep 10, 2021
@xuri
Copy link
Member

xuri commented Sep 10, 2021

Thanks for your issue, I have fixed it, please try to use the master branch code.

@ipopa
Copy link
Author

ipopa commented Sep 10, 2021

It works, thank you

jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
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