Home > Backend Development > PHP Tutorial > PHP导出为excel文件时,身份证却以科学计数法显示,怎么正常显示

PHP导出为excel文件时,身份证却以科学计数法显示,怎么正常显示

WBOY
Release: 2016-06-13 13:38:56
Original
1153 people have browsed it

PHP导出为excel文件时,身份证却以科学计数法显示,如何正常显示
PHP在把数据库中的记录导出为excel文件时,生成的excel文件中的身份证一列,却以科学计数法显示的,
不知有什么法子,让其全部显示。代码如下:
  header("content=text/html; charset=gb2312");
header("Content-type:application/vnd.ms-excel");
date_default_timezone_set('PRC'); //解决时间少了8小时的问题;
header("Content-Disposition:attachment;filename=".date('Y_m_d_H_i_s').".xls");
echo "

";
echo "";
echo "";
echo "";
echo "";
echo "";
echo "";
$i = $number;
while($rows = mysql_fetch_array($result)){
echo "";
echo "";
echo "";
echo "";
echo "";
$i--;  
}
echo "
学员信息表
序号学员姓名身份证号码
".$i."".$rows['app_name']."".$rows["app_id_card"]."
";
?>
需要说明的是:数据库中身份证的字段属性用的是:varchar

另外,如果在导出的时候,前面加一个 ' 

echo "'".$rows["app_id_card"]."";

在excel中身份证也会以全部显示,不过生成的号码前面会有一个 ',
双击这个单元格后,这个 ' 会在 左上角生成一个小三角。



------解决方案--------------------
以文本格式储存
------解决方案--------------------
echo " ".$rows["app_id_card"]."";

这样可以,无伤大雅
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template