本例子不是读取excel或生成新的excel,而是读取现有的excel文件,然后修改excel中的数据,就像修改mysql中数据一样的哦。
canread($dir . $templatename)) { $phpreader = new phpexcel_reader_excel5(); if (!$phpreader->canread($dir . $templatename)) { echo '无法识别的excel文件!'; return false; }}//读取excel$phpexcel = $phpreader->load($dir . $templatename);//读取工作表1$currentsheet = $phpexcel->getsheet(0);$currentsheet->setcellvalue('b13', iconv('gbk', 'utf-8', $txt)); //表头赋值////实例化excel写入类$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 . ''); //输出模板名称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');?>
文章网址:
随意转载^^但请附上教程地址。