laravel excel 导出 - 数据存储为文本而不是数字

问题描述

我正在尝试导出一个包含所有数据的 excel。 下载excel后,整数单元格存储为带有错误的绿色小三角形的文本

The number in this cell is formatted as text or preceded by an apostrophe

我也尝试使用 setColumnFormat 函数将所有列转换为 int 数据类型,但没有奏效

$sheet->setColumnFormat(array('A:AP' => \PHPExcel_Style_NumberFormat::FORMAT::NUMBER));

同时在单元格中推送数据时,我正在使用 number_format 函数也不起作用。

寻求帮助!

解决方法

我认为删除 number_format() 后应该可以解决此函数返回 string 类型而不是 number。请检查 simplified versionPHP Manual