.0 数字,即如果单元格值为 123 ,它读作 123.0
.0
123
123.0
try { $inputFileType = IOFactory::identify($path); try { $reader = IOFactory::createReader($inputFileType); $reader->setReadDataOnly(true); $valuesSpreadsheet = $reader->load($path); try { $spreadsheetArr = $valuesSpreadsheet->getActiveSheet()->toArray(); dd($spreadsheetArr); } } }
所以输出就像
$arr = ['A', 'B', 123.0]
我想要达到的是
$arr = ['A', 'B', '123']
你能试试这样的吗:
$valuesSpreadsheet->getActiveSheet()->getStyle('C:C') ->getNumberFormat() ->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);