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
preserve leading zero's on xlsx output #39
Comments
I am patching /tablib/formats/_xlsx.py on my local install to try to use Cell.set_value_explicit() when the value in the cell begins with a zero and its len() is greater than 1. |
If it doesn't break anything, you should send a pull request :) |
There is a little bit of refactoring I would like to do in dset_sheet() |
Most of my assignments to ws.cell() are occurring in the TypeError except clause in _xlsx.py. What I have is working, however, "if it doesnt break anything" has not been proven out. I am under the gun with this report, so I am going to use this patch as-is. Can I send you a diff maybe to use against your unittests? |
Is column ordering supported in various outputs? I am looking around, |
It appears to export the columns in reverse order that they are imported. I am going to reverse that so the order of the columns is preserved. |
This change keeps the order of columns in the xlsx output. Only the last line is changed. The others are there for context.
|
That patch yesterday was naive. The order of columns does not appear to be controllable. It worked for one case, but stopped working when some new columns were added. My reason for them falling into the TypeError probably stems from me running this on aix which is using a latin-1 encoding. To preserve the leading zero's in openpyxl, it is just the difference between setting a cells value property and calling the method cell.set_value_explicit(value). I attempted to detect when the cell contains a string with len gt 1 and position 0 is a zero. That never worked out (i think due to the latin-1 encoding.) |
I have a fork that I am patching this and testing. |
While working another project, I tried your xls output and it appears to "do the right thing" by default. So, it is only the openpyxl output I suspect. |
This issue can be closed. It appears that Eric is patching openpyxl. I guess this issue can be used to patch your internal openpyxl. References: |
This commit specifically works a lot better than what you have currently. https://bitbucket.org/ericgazoni/openpyxl/changeset/ea3779bcd3a5#chg-openpyxl/cell.py |
This project is in a bit of a crisis state — it's really useful, and I use regularly. However, I wrote it several years ago and haven't touched it since. In order to get the project into a stable state I'm closing all issues and pull requests to get a "fresh slate" Don't take this as aggressive — it's just necessary for the project to make any progress any time soon (it's pretty clear the project is effectively unmaintained at the moment). Great things to come! Please watch the GitHub logs and feel free to re-open this discussion soon. I just need to really it into a good state first. ✨ ❤️ ✨ |
Trying to determine the best way to handle this. Tablib is keeping them correctly. However, openpyxl needs an alternate syntax if you want to assign a literal.
An example is if I have a column of zip codes or social security numbers that I do not want to be interpreted as numeric.
The text was updated successfully, but these errors were encountered: