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

Wrong long int value exported #197

Open
fengsp opened this issue Jun 29, 2015 · 2 comments
Open

Wrong long int value exported #197

fengsp opened this issue Jun 29, 2015 · 2 comments
Labels

Comments

@fengsp
Copy link

fengsp commented Jun 29, 2015

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.

@hugovk
Copy link
Member

hugovk commented Oct 19, 2019

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:

@claudep
Copy link
Contributor

claudep commented Oct 22, 2019

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...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants