我正在研究一个项目,我需要存储一个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;
}
?>
答案 0 :(得分:0)
MS excel不喜欢大数字。它建议如果您不需要对数字进行任何数学运算,那么您将单元格的类型更改为文本(类似于使用varchar将数字存储在mysql中的原因)。
可能的解决方法是将文件作为.csv输出和下载,并在Excel中打开,并为列提供文本格式。
否则,我认为您应该能够使用PHPExcel进行格式化