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

AddTables creates invalid files if the tables name has spaces #1468

Closed
wlbr opened this issue Feb 13, 2023 · 2 comments
Closed

AddTables creates invalid files if the tables name has spaces #1468

wlbr opened this issue Feb 13, 2023 · 2 comments
Labels
enhancement New feature or request

Comments

@wlbr
Copy link

wlbr commented Feb 13, 2023

Hi,

AddTables creates corrupt files if the name attribute is using spaces.

Either it should be more resilient and replace the spaces with _ (what Excel will do anyway),
or this should be documented and an error should be thrown.

So this will work, but it took me quite a while to figure out the reason for the corruption:

err := f.AddTable(sheetname, fmt.Sprintf("B%d:J%d", datastart, len(issues)+datastart), &excelize.TableOptions{
		Name:              strings.ReplaceAll("Issues "+sheetname, " ", "_"),
		StyleName:         "TableStyleMedium2",
		ShowFirstColumn:   false,
		ShowLastColumn:    false,
		ShowRowStripes:    &disable,
		ShowColumnStripes: false,
	})

Regards,
Michael

@xuri xuri added the enhancement New feature or request label Feb 13, 2023
@xuri xuri added the in progress Working in progress label Feb 13, 2023
@xuri xuri closed this as completed in 363fa94 Feb 13, 2023
@xuri
Copy link
Member

xuri commented Feb 13, 2023

Thanks for your issue. I have added checks for the table name, please upgrade to the master branch code, and this patch will be released in the next version.

@xuri xuri removed the in progress Working in progress label Feb 13, 2023
@wlbr
Copy link
Author

wlbr commented Feb 13, 2023

Wow, now that' a quick response!
Thanks a lot!

xuri added a commit to JDavidVR/excelize that referenced this issue Jul 11, 2023
… constant `ErrTableNameLength`

- XML Structure field typo fixed
- Update documentation for the `AddChart` function
- Update unit test
jenbonzhang pushed a commit to jenbonzhang/excelize that referenced this issue Oct 22, 2023
… constant `ErrTableNameLength`

- XML Structure field typo fixed
- Update documentation for the `AddChart` function
- Update unit test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants