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

"Invalid character / found in sheet title" during export to XLSX #489

Closed
mpasternak opened this issue Feb 28, 2021 · 4 comments · Fixed by #490 or #510
Closed

"Invalid character / found in sheet title" during export to XLSX #489

mpasternak opened this issue Feb 28, 2021 · 4 comments · Fixed by #490 or #510

Comments

@mpasternak
Copy link
Contributor

Hi there,

it looks like tablib could automatically replace some characters when exporting to XLS, what do you think? The problem occurs when I export a sheet with a slash inside its title:

  File "/Users/mpasternak/.virtualenvs/bpp/lib/python3.8/site-packages/tablib/formats/_xlsx.py", line 53, in export_book
    ws.title = dset.title if dset.title else 'Sheet%s' % (i)
  File "/Users/mpasternak/.virtualenvs/bpp/lib/python3.8/site-packages/openpyxl/workbook/child.py", line 93, in title
    raise ValueError(msg)
ValueError: Invalid character / found in sheet title

Devs, please let me know if this is desired and I'll think about a patch.

@mpasternak mpasternak changed the title Invalid character / found in sheet title "Invalid character / found in sheet title" during export to XLSX Feb 28, 2021
@claudep
Copy link
Contributor

claudep commented Feb 28, 2021

Would you suggest replacing invalid chars (INVALID_TITLE_REGEX = re.compile(r'[\\*?:/\[\]]') with underscores?

@mpasternak
Copy link
Contributor Author

Seems legit. Optionally make the underscore configurable with something else.

@claudep
Copy link
Contributor

claudep commented Feb 28, 2021

Feel free to suggest a patch!

@mpasternak
Copy link
Contributor Author

OK cool, PR coming soon

mpasternak added a commit to mpasternak/tablib that referenced this issue Feb 28, 2021
"Invalid character / found in sheet title" during export to XLSX, GitHub issue jazzband#489
mpasternak added a commit to mpasternak/tablib that referenced this issue Mar 1, 2021
marisn added a commit to marisn/tablib that referenced this issue Nov 2, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants