PHPExcel在大整数电话号码前附加[< = 9999999]

时间:2017-09-20 04:25:20

标签: php excel phpexcel

我正在使用此处的excelToArray函数:https://gist.github.com/calvinchoy/5821235

function excelToArray($filePath, $header = true) {
    require_once("./PHPExcel/Classes/PHPExcel.php"));
    //Create excel reader after determining the file type
    $inputFileName = $filePath;
    /**  Identify the type of $inputFileName  **/
    $inputFileType = PHPExcel_IOFactory::identify($inputFileName);
    /**  Create a new Reader of the type that has been identified  **/
    $objReader = PHPExcel_IOFactory::createReader($inputFileType);
    /** Set read type to read cell data onl **/
    // $objReader->setReadDataOnly(true); removed because: https://stackoverflow.com/questions/46142706/
    /**  Load $inputFileName to a PHPExcel Object  **/
    $objPHPExcel = $objReader->load($inputFileName);
    //Get worksheet and built array with first row as header
    $objWorksheet = $objPHPExcel->getActiveSheet();
    //excel with first row header, use header as key
    if($header){
        $highestRow = $objWorksheet->getHighestRow();
        $highestColumn = $objWorksheet->getHighestColumn();
        $headingsArray = $objWorksheet->rangeToArray('A1:'.$highestColumn.'1',null, true, true, true);
        $headingsArray = $headingsArray[1];
        $r = -1;
        $namedDataArray = array();
        for ($row = 2; $row <= $highestRow; ++$row) {
            $dataRow = $objWorksheet->rangeToArray('A'.$row.':'.$highestColumn.$row,null, true, true, true);
            if ((isset($dataRow[$row]['A'])) && ($dataRow[$row]['A'] > '')) {
                ++$r;
                foreach($headingsArray as $columnKey => $columnHeading) {
                    $namedDataArray[$r][$columnHeading] = $dataRow[$row][$columnKey];
                }
            }
        }
    }
    else{
        //excel sheet with no header
        $namedDataArray = $objWorksheet->toArray(null,true,true,true);
    }
    return $namedDataArray;
}

我在Excel中有一个示例电子表格。这是:

预览:https://drive.google.com/open?id=0B2GilRTNrTzKRUVsQWhnQkRLUmM

直接下载:https://drive.google.com/uc?authuser=0&id=0B2GilRTNrTzKRUVsQWhnQkRLUmM&export=download

问题在于,当我上传电子表格时,我看到电话号码(我提供的电子表格中只是大整数(例如:2345556789))正在进入{{1在他们面前。例如:[<=9999999]

导致这种情况的原因以及如何将其简单地以字符串(甚至是int)的形式读取?

0 个答案:

没有答案