我正在做一个项目,我需要存储一个25位数的数字。当我尝试使用BIGINT
数据格式时,它显示超出范围。然后我使用VARCHAR数据类型存储它。但我还需要把它导出到MS-EXCEL
页。当我导出它时,Excel只显示13-14个较高的数字,其余的较低的数字被四舍五入,使它们0的。
我的源代码如下所示:
<?php
$conn = mysqli_connect("localhost", "root", "", "dis");
$output='';
$sql= "SELECT `polid`, `inscompanyid`, polno FROM `policies` order by polid desc";
$res = mysqli_query($conn, $sql) or die(mysqli_error($conn));
if(!$res || mysqli_num_rows($res)){
$output .='
<table class="table" border="1">
<tr>
<th>asdf</th>
<th>qwer</th>
<th>zcxv</th>
</tr>
';
while($row=mysqli_fetch_assoc($res))
{
$output.='
<tr>
<td>'.$row["polid"].'</td>
<td>'.$row["inscompanyid"].'</td>
<td>'.$row["polno"].'</td>
</tr>
';
}
$output.='</table';
//header("Content-Type: application/xls");
//header("Content-Disposition: attachment; filename=download.xls");
echo $output;
}
?>
根据此链接http://answers.microsoft.com/en-us/msoffice/forum/msoffice_excel-mso_other/when-i-am-entering-16-digit-number-in-excel-its/7f50828d-77b4-4ad2-8ea7-0411d0236bd0
MS excel不喜欢大数字。它建议,如果你不需要做任何数学上的数字,你改变单元格的类型为文本(类似的原因,你使用varchar来存储你的数字在mysql)。
这是可能的一个解决方案,可以输出和下载您的文件为。csv和打开excel与文本格式的列。
否则,我认为你应该能够使用PHPExcel进行格式化