In this example, you can read an existing Excel file instead of reading an Excel file or generating a new Excel file, and then modify the data in the Excel file, just like modifying the data in mysql .? Directory for storing php templates $ dir... in this example, instead of reading an Excel file or generating a new Excel file, you can read an existing Excel file and modify the data in the Excel file, just like modifying the data in mysql.
CanRead ($ dir. $ templateName) {$ PHPReader = new PHPExcel_Reader_Excel5 (); if (! $ PHPReader-> canRead ($ dir. $ templateName) {echo 'Unrecognized Excel file! '; Return false ;}/// read Excel $ PHPExcel = $ PHPReader-> load ($ dir. $ templateName); // read the worksheet 1 $ currentSheet = $ PHPExcel-> getSheet (0); $ currentSheet-> setCellValue ('b13', iconv ('gbk ', 'utf-8', $ txt); // header assignment // instantiate the Excel writing class $ PHPWriter = new PHPExcel_Writer_Excel2007 ($ PHPExcel); ob_start (); header ("Content-Type: application/force-download"); header ("Content-Type: application/octet-stream"); header ("Content-Type: ap Plication/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');?>
Article URL:
Reprint ^ at will, but please attach the tutorial address.