0
我有下面的代碼,但是當我通過導入過程運行我的CSV時,我的前導零不見了。例如,我有一個數字字段,例如「0010」,但在它來自下面的代碼後,數字是「10」。有人有建議嗎?PHPexcel刪除前導零的問題
\t $objPHPExcel = new PHPExcel();
\t
\t function ci_import($inputFileName){
\t \t
\t \t \t //echo "calling....";exit;
\t \t \t
\t \t try {
\t \t \t $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
\t \t \t $objReader = PHPExcel_IOFactory::createReader($inputFileType);
\t \t \t $objPHPExcel = $objReader->load($inputFileName);
\t \t } catch (Exception $e) {
\t \t \t die('Error loading file "' . pathinfo($inputFileName, PATHINFO_BASENAME)
\t \t \t . '": ' . $e->getMessage());
\t \t }
\t \t
\t \t $sheets = count($objPHPExcel->getAllSheets());
\t \t //echo $sheets;
\t \t //echo "<pre>";
\t \t $arr=array();
\t \t foreach($objPHPExcel->getAllSheets() as $sheet){
\t \t \t $title = $sheet->getTitle();
\t \t \t $arr[$title]=array();
\t \t \t $rows= array();
\t \t \t // fetch the data
\t \t \t foreach ($sheet->getRowIterator() as $row)
\t \t \t {
\t \t \t \t $cols= array();
\t \t \t \t $cellIterator = $row->getCellIterator();
\t \t \t \t $cellIterator->setIterateOnlyExistingCells(false); // This loops all cells,
\t \t \t \t foreach ($cellIterator as $cell)
\t \t \t \t {
\t \t \t \t \t $cols[]=$cell->getValue();
\t \t \t \t }
\t \t \t \t $rows[] = $cols;
\t \t \t }
\t \t \t $arr[$title]=$rows;
\t \t \t
\t \t \t
\t \t \t \t \t }
\t \t
\t \t return $arr;
\t \t print_r($arr);
\t \t
\t }