tablib
tablib copied to clipboard
Wrong long int value exported
I have the code:
import tablib
data = tablib.Dataset()
data.headers = ['test_id']
a = 568883383628111872
data.append([a])
with open('test.xls', 'wb') as f:
f.write(data.xls)
Which produces one xls file with id as 568883383628112000.
Reproducible directly with newest openpyxl 3.0.0, Python 3.7.4:
from openpyxl import Workbook
wb = Workbook()
# Grab the active worksheet
ws = wb.active
# Data can be assigned directly to cells
ws["A1"] = 568883383628111872
# Save the file
wb.save("sample.xlsx")
Reported to openpyxl:
- https://bitbucket.org/openpyxl/openpyxl/issues/1355/wrong-long-int-value-exported
Openpyxl will not fix it as this is an Excel limitation (https://docs.microsoft.com/en-us/office/troubleshoot/excel/long-numbers-incorrectly-in-excel).
We could detect such values and force them to str to force a text format for such numbers. To be tested...