我尝试读取电子表格,但是当一个单元格中只有数字时,会将其放置为.0
位数字,即,如果该单元格值为123
,则它将其读取为{{1 }} int。有没有办法将它们读取为原始字符串?
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]
答案 0 :(得分:0)
您能尝试这样的事情吗?
$valuesSpreadsheet->getActiveSheet()->getStyle('C:C')
->getNumberFormat()
->setFormatCode(\PhpOffice\PhpSpreadsheet\Style\NumberFormat::FORMAT_TEXT);