简体   繁体   English

从openpyxl中的数字中删除科学记数法

[英]Removing scientific-notation from number in openpyxl

When a number is long in my excel document, Excel formats the cell value to scientific notation (ex 1.234567e+5) while the true number still exists in the formula bar at the top of the document (ex 123456789012). 当我的Excel文档中的数字很长时,Excel会将单元格值格式化为科学记数法(例如1.234567e + 5),而真正的数字仍然存在于文档顶部的公式栏中(例如123456789012)。

I want to convert this number to a string for my own purposes, but when I do, the scientific notation is captured, rather than the true number. 我想将此数字转换为字符串以用于我自己的目的,但是当我这样做时,会捕获科学记数法,而不是真正的数字。 How can I assure that it's the true number that is being converted to a string? 我怎样才能确保它是转换为字符串的真实数字?

Python will ignore the formatting that Excel uses for anything other than dates and times, so you should just be able to convert the number to a string. Python将忽略Excel用于除日期和时间之外的任何格式的格式,因此您应该只能将数字转换为字符串。 You will, however, be limited by Excel's precision. 但是,您将受到Excel精度的限制。 The OOXML file format is not suitable for some tasks notably those with historical dates or high precision times. OOXML文件格式不适用于某些任务,特别是那些具有历史日期或高精度时间的任务。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM