php - 大整数在excel中以科学计数法显示
问题描述
我正在使用下面的 php 将 mysql 数据导出到 excel 表中。
<?php
header("Content-Type: application/xls");
header("Content-Disposition: attachment; filename=$filename.xls");
header("Pragma: no-cache");
header("Expires: 0");
?>
<table width="100%" border="0" cellspacing="0" cellpadding="0" >
<tr>
<th class="excel_style">Order Type</th>
<th class="excel_style">Order Number</th>
<th class="excel_style">EAN</th>
<th class="excel_style">Article #</th>
</tr>
<?php
// mysqli query comes here
while($result = mysqli_fetch_assoc($res)){?>
<td><?php echo $result['order_type'] ;?></td>
<td><?php echo $result['order_number'];?></td>
<td><?php echo $result['EAN'];?></td>
<td><?php echo $result['article_number'];?></td>
</tr>
<?php } ?>
</table>
一切正常,但在 EAN 和文章 # 列中生成 excel 报告后,值显示为科学计数法,如下所示。
4.04623E+12 but the original value is - 4046228026756
. 因此,当用户打开 Excel 工作表时,相关列应显示为原始值。我怎样才能做到这一点?任何帮助将不胜感激。
有没有办法告诉excel单元格的数据类型是String类型。像下面的一些东西
$excel1->setActiveSheetIndex(0)->setCellValueExplicit('C'.$k, $row['EAN'],PHPExcel_Cell_DataType::TYPE_STRING)
解决方案
推荐阅读
- java - @AutoConfigureWebTestClient(timeout = "600000") 没有效果
- c++ - 我无法让 ofstream 功能工作
- reactjs - 移除 componentWillUnmoint 中的匿名监听器
- ruby - 在 SQL Server 2008 R2 上连接 ruby 时,Adaptive Server 连接失败 TinyTDS::error
- r - 提高 R 中 For 循环的性能以计算所有 Shapley 值
- javascript - 布尔状态值在第二次提交时更改为未定义
- ios - 将捆绑 ID 注册到应用商店证书和 ID 时出现问题
- xamarin.forms - 在 xamarin.forms 中单击按钮调用异步任务
- python - VSCode 无法导入“示例”pylint(导入错误)
- hyperledger-fabric - 可以在 CLI 命令的帮助下完成 fabric-ca 身份验证