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

Error: the same name table already exists, when first deleting and then adding the table with the same name back. #1751

Closed
keqin404 opened this issue Dec 12, 2023 · 3 comments
Labels
duplicate This issue or pull request already exists
Projects

Comments

@keqin404
Copy link

Description

I meet Error: the same name table already exists, when first deleting and then adding the table with the same name back.

Steps to reproduce the issue:

  1. create a template excel file named Book1.xlsx with Sheet1 and Table1
  2. run sample code

Describe the results you received:

the same name table already exists

Describe the results you expected:

the table should be added.

Output of go version:

go version go1.20.5 darwin/amd64

Excelize version or commit ID:

github.com/xuri/excelize/v2 v2.8.0

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

MacOS

Sample code:

package main

import (
	"fmt"

	"github.com/xuri/excelize/v2"
)

func main() {
	f, err := excelize.OpenFile("Book1.xlsx")
	if err != nil {
		fmt.Println(err)
		return
	}
	defer func() {
		// Close the spreadsheet.
		if err := f.Close(); err != nil {
			fmt.Println(err)
		}
	}()
	fmt.Println("before delete:")
	fmt.Println(f.GetTables("Sheet1"))
	f.DeleteTable("Table1")
	fmt.Println("after delete:")
	fmt.Println(f.GetTables("Sheet1"))
	err = f.AddTable("Sheet1", &excelize.Table{Range: "A1:B3", Name: "Table1"})
	if err != nil {
		fmt.Println(err)
		return
	}
}
@xuri
Copy link
Member

xuri commented Dec 12, 2023

Thanks for your issue. This issue duplicates with #1682, and it has been fixed. Please upgrade to the master branch code, and this patch will be released in the next version. If it still not work, please let me know.

@xuri xuri added the duplicate This issue or pull request already exists label Dec 12, 2023
@xuri xuri added this to Bugfix in v2.8.1 Dec 12, 2023
@keqin404
Copy link
Author

Thank you.

@xuri
Copy link
Member

xuri commented Dec 12, 2023

I'll close this issue, if you have any questions, please let me know to reopen this anytime.

@xuri xuri closed this as completed Dec 12, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
duplicate This issue or pull request already exists
Projects
No open projects
v2.8.1
Bugfix
Development

No branches or pull requests

2 participants