Home  >  Article  >  Backend Development  >  php 将excel导入MySQL 数据库后,怎么使得它以文本形式显示

php 将excel导入MySQL 数据库后,怎么使得它以文本形式显示

WBOY
WBOYOriginal
2016-06-13 12:14:43931browse

php 将excel导入MySQL 数据库后,如何使得它以文本形式显示
php 将excel导入MySQL 数据库后,如何使得它以文本形式显示
比如excel里面是  9787509345030
导入数据库之后变成了  9.78750934503E+12
php去读数据库的数据,发现也是9.78750934503E+12
好恼火,求助,心情很复杂。
它好像是数值型的了,我明明是
$number= implode('',explode('-',$data->sheets[0]['cells'][$i][1]));
$number = strval($number);
把它搞成字符串型了,为啥米还是数值型????
------解决思路----------------------
你的 9787509345030 在 excel 不是以字符串形式存储的('9787509345030),而是以样式表方式修饰的(不然也是科学计数法表示)
你可以尝试使用 getFormattedValue 方法读取,而不是 getValue 方法读取

你的 $data->sheets[0]['cells'][$i][1] 是有问题的

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:用swagger-php/ui作API测试Next article:ApiGen装配