-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
duplicate sheets #33
Comments
@xuri in my case, copy sheet didn't work. I ran this using master branch on a526e90 n := "1"
last := f.NewSheet(n)
err := f.CopySheet(1, last) above code will return error about wrong index. The actual excel only contain 1 sheet, but the value when I ran this n := "1"
last := f.NewSheet(n)
err := f.CopySheet(1, 2) that will not return any error, but the sheets is not copied into newly created sheet. I will send the excel file via email if it have to. |
Hi @muhrifqii, thanks for your feedback, you can send me the file with credential data masking. |
Hi @muhrifqii, I have fixed this issue. Please try to upgrade the library with the master branch code, and this bug fix will be published in the next release version. Also, we need to get the source worksheet index before copy to the target worksheet: package main
import "github.com/xuri/excelize"
func main() {
n := "1"
f, err := excelize.OpenFile("blank.xlsx")
if err != nil {
panic(err)
}
last := f.NewSheet(n)
if err := f.CopySheet(f.GetSheetIndex("Sheet2"), last); err != nil {
panic(err)
}
f.SetActiveSheet(last)
if err := f.SaveAs("./Book1.xlsx"); err != nil {
panic(err)
}
} |
Capability to duplicate a sheet, like PowerShell/excel's $wb.sheets.item(1).copy($wb.sheets.item(2)). Perhaps something like:
// sheet at index 1 already exists...
xlsx.NewSheet(2, "sheet2")
xlsx.CopySheet(1, 2)
The text was updated successfully, but these errors were encountered: