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

Copied sheet mirrors old one #288

Open
the-goodies opened this issue May 31, 2019 · 1 comment
Open

Copied sheet mirrors old one #288

the-goodies opened this issue May 31, 2019 · 1 comment

Comments

@the-goodies
Copy link

All copied sheets reference the same underlying one. So modifying any sheet, it applies to all of them.

func sampleCopySheet() {
	wb := spreadsheet.New()
	defer wb.SaveToFile("error.xlsx")

	sheet := wb.AddSheet()
	sheet.Cell("A1").SetString("one")

	sheet, _ = wb.CopySheetByName("Sheet 1", "Sheet 2")
	sheet.Cell("A1").SetString("two")

	sheet, _ = wb.CopySheetByName("Sheet 1", "Sheet 3")
	sheet.Cell("A1").SetString("three")
}

Correct result: "Sheet 1:A1" - "one"; "Sheet 2:A1" - "two" ; "Sheet 3:A1" - "three".
How it is now: "Sheet 1:A1" - "three"; "Sheet 2:A1" - "three" ; "Sheet 3:A1" - "three".

@gunnsth
Copy link
Contributor

gunnsth commented Nov 18, 2019

Looks like this requires a deep copy of the sheet contents. Maybe a new function called DeepCopySheetByName to keep compatibility.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants