我希望将我的二维数组保存到 .xls 文件中。如果使用此代码,则保存数据时不带前导零:
$arr = array(
array("01", "02", "03"),
array("001", "02", "03"),
array("00001", "02", "03"),
);
// include PHPExcel library
$objPHPExcel = new PHPExcel();
$objPHPExcel->getActiveSheet()->fromArray($arr);
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save("file.xls");
如果改用它,01
则另存为00001
:
......
$objPHPExcel->getActiveSheet()->fromArray($arr);
$objPHPExcel->getActiveSheet()->getStyle('A1:C3')->getNumberFormat()->setFormatCode("00000");
.....
我怎么解决这个问题?如何正确地将数组中的原始数据保存到 .xls 文件中?