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

Delete Table not working #1682

Closed
abdelaziz-ouhammou opened this issue Oct 5, 2023 · 4 comments
Closed

Delete Table not working #1682

abdelaziz-ouhammou opened this issue Oct 5, 2023 · 4 comments
Labels
bug Something isn't working

Comments

@abdelaziz-ouhammou
Copy link
Contributor

abdelaziz-ouhammou commented Oct 5, 2023

Go: 1.21.1
Excelize: master

Updating a table's range by removing it and creating it again doesn't work.

func main() {
	f, err := excelize.OpenFile("template.xlsx")
	if err != nil {
		panic(err)
	}

	err = f.SetSheetRow("Data", "A7", &[]any{"2023-10-06", 140})
	if err != nil {
		panic(err)
	}
	err = f.DeleteTable("Table1")
	if err != nil {
		panic(err)
	}
	err = f.AddTable("Data", &excelize.Table{
		Name:  "Table1",
		Range: "A1:B7",
	})
	if err != nil {
		panic(err)
	}
	err = f.SaveAs("output.xlsx")
	if err != nil {
		panic(err)
	}



}

//panic: the same name table already exists

Excelize.zip
Also Is there a way to refresh the range of a chart ? or make the chart react to a table new row ?

@xuri xuri added confirmed This issue can be reproduced in progress Working in progress labels Oct 5, 2023
@xuri xuri closed this as completed in 95fc35f Oct 5, 2023
@xuri
Copy link
Member

xuri commented Oct 5, 2023

Thanks for your issue. This issue has been fixed, please try to upgrade the master branch code, and this patch will be released in the next version. This library does not support change the data range of the chart currently, but you can delete the chart and create a new chart instead of that.

@xuri xuri removed the in progress Working in progress label Oct 5, 2023
@abdelaziz-ouhammou
Copy link
Contributor Author

abdelaziz-ouhammou commented Oct 5, 2023

@xuri I can confirm the issue is fixed. However DeleteTable deletes the table header ? is this the intended behavior ?

Also Add table doesn't have a way to specify a header for the new table.

If i have the header as

Date, Values
2023-10-05, 10

// After Delete Header
2023-10-05, 10

// After AddTable
Column1, Column2
2023-10-05, 10

is there a way to do this without losing the table header ?

@xuri
Copy link
Member

xuri commented Oct 6, 2023

Yes, I think we need to keep all cells value in the table range when deleting table, these section code is not required, would you like to create a pull request for that?

@xuri xuri added bug Something isn't working and removed confirmed This issue can be reproduced labels Oct 6, 2023
@abdelaziz-ouhammou
Copy link
Contributor Author

Yes I will by the end of today.

abdelaziz-ouhammou added a commit to abdelaziz-ouhammou/excelize that referenced this issue Oct 6, 2023
- DeleteTable does not delete table header values.
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
…ing the table

- Move worksheet-related functions in one place
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