标签:this adc put 电话 ror cto length 名称 load
include KIF_PATH . ‘/PHPExcel.class.php‘; //$inputFileType = ‘Excel5‘; $inputFileType = ‘Excel2007‘; $filePath = $this->excelFile; $objReader = \PHPExcel_IOFactory::createReader($inputFileType); if (!$objReader->canRead($filePath)) { echo ‘error file type‘; exit(); } $objExcel = $objReader->load($filePath); $objSheet = $objExcel->getSheet(0); $allRow = $objSheet->getHighestRow(); $readColumns = array( ‘D‘, // 专柜名称 ‘F‘, // 详细地址 ‘J‘, // 省 ‘K‘, // 市 ‘L‘, // 店铺电话 ); $startRow = 2; for ($currentRow = $startRow; $currentRow <= $allRow; $currentRow++) { $row = $currentRow; $rowStr = ‘‘; foreach ($readColumns as $col) { $value = $objSheet->getCell($col . $row)->getValue(); $value = trim($value); if (strpos($value, ‘,‘) !== false) { $value = str_replace(‘,‘, ‘,‘, $value); echo $value . ‘ has , change to 中文逗号 ‘; echo PHP_EOL; } // 如果有 <202d>, 则表格内是空的 $string = $value; $tmpRes = array(); $length = strlen($string); for ($i = 0; $i < $length; $i++) { $tmpRes[] = ‘0x‘ . strtolower(base_convert(ord($string{$i}), 10, 16));//ord($string[$i]); } $tmpStr = implode(‘‘, $tmpRes); if (strpos($tmpStr, ‘0xe20x800xad‘) !== false) { echo $value . ‘ has special char, will set empty ‘; echo PHP_EOL; $value = ‘‘; } // end foreach ($wordSearch as $search => $replace) { $rowStr = str_replace($search, $replace, $rowStr); } $rowStr = substr($rowStr, 0, -1); echo $rowStr . PHP_EOL; file_put_contents($csvFile, $rowStr . PHP_EOL, FILE_APPEND); }
标签:this adc put 电话 ror cto length 名称 load
原文地址:https://www.cnblogs.com/bandbandme/p/12083092.html