1、composer引入php处理excel包:box/spout
2、处理函数示例:
/** * @param string $filePath 文件绝对路径 * @return array * @throws */ public function readFromExcel(string $filePath) { $reader = ReaderEntityFactory::createXLSXReader(); $reader->open($filePath); $fileDataArr = []; foreach ($reader->getSheetIterator() as $sheet) { foreach ($sheet->getRowIterator() as $RowKey => $row) { if ($RowKey == 1) { continue; } foreach($row->getCells() as $CellKey => $value){ switch ($CellKey){ case 1: $orderId = $value->getValue(); break; default: case 0: $shopId = $value->getValue(); break; } } $fileDataArr[$shopId][] = $orderId; } break; } $reader->close(); return fileDataArr; }
TRANSLATE with x English TRANSLATE with COPY THE URL BELOW Back EMBED THE SNIPPET BELOW IN YOUR SITE Enable collaborative features and customize widget: Bing Webmaster Portal Back 标签:格式化,filePath,Excel,value,break,location,reader,php From: https://www.cnblogs.com/jytblog/p/16768542.html