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
Feature request: add user defined types to write() #631
Labels
Comments
jmcnamara
added a commit
that referenced
this issue
Jun 9, 2019
Add support for adding user defined types and callbacks to write additional data types. Issue #631
Initial working code is available to test this on the https://github.com/jmcnamara/XlsxWriter/tree/write_handler branch. |
Closed
jmcnamara
added a commit
that referenced
this issue
Jun 9, 2019
Add support for adding user defined types and callbacks to write additional data types. Issue #631
jmcnamara
added a commit
that referenced
this issue
Sep 13, 2019
Add support for adding user defined types and callbacks to write additional data types. Issue #631
jmcnamara
added a commit
that referenced
this issue
Sep 13, 2019
Added in version 1.2.1. See: https://xlsxwriter.readthedocs.io/working_with_data.html#writing-user-defined-types |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The worksheet
write()
method maps common Python types to corresponding Excel types. It deliberately doesn't try to map unknown/unhandled types to Excel strings (for example) since the decision on the type mapping should be made by the end user.This mapping can be done by remapping data types before calling
write()
but there are cases where it is cleaner to do it inwrite()
.This is available in the Perl version of this module in a method called add_write_handler(). The Perl version relies on regular expressions but an equivalent version in Python could use types.
For example, currently if you write an unhandled data type you get an TypeError:
Output:
With the proposed new API you could add a handler/callback for this, or other, types:
Output:
The text was updated successfully, but these errors were encountered: