This article mainly introduces the PHP reading Excel file examples, as well as the update modification function, the need for friends can refer to the following
Code is as follows://template storage Directory $dir = $DOCUMENT _root. ' /backoffice/admin/oemcheck/'; $templateName = ' 1.xlsx '; $outputFileName = ' template. xlsx '; $txt = ' Test '; //materialized Excel reading class $PHPReader = new phpexcel_reader_excel2007 (); if (! $PHPReader->canread ($dir. $templateName)) { $PHPReader = new Phpexcel_reader_excel5 (); if (!$ Phpreader->canread ($dir. $templateName)) { echo ' unrecognized Excel file! '; return false; &NBSP}//Read Excel $PHPExcel = $PHPReader->load ($dir. $templateName); READ worksheet 1 $currentSheet = $PHPExcel->getsheet (0); $currentSheet->setcellvalue (' B13 ', iconv (' GBK ', ' utf-8 ', $txt))//Table header assignment///materialized Excel write class $PHPWriter = new Phpexcel_writer_excel2007 ($PHPExcel); Ob_start (); Header ("Content-type:application/force-download"); Header ("Content-type:application/octet-stream"); Header ("Content-type:application/download"); Header (' Content-disposition:attachment;filename= '. $outputFileName. ' "');//Output Template Name header (" Content-transfer-encoding:binary "); Header ("Last-modifIED: ". Gmdate (" D, D M Y h:i:s ")." GMT "); Header (' Pragma:public '); Header (' expires:30 '); Header (' Cache-control:public '); $PHPWriter->save (' php://output ');