...
代码如下 |
|
| $dir = $DOCUMENT_ROOT.'/backoffice/admin/oemcheck/';
$templateName = '1.xlsx';
$outputFileName = '模板.xlsx';
$txt='test';
//实例化Excel读取类
$PHPReader = new PHPExcel_Reader_Excel2007();
if(!$PHPReader->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写入类www.111cn.net
$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');
原文来自:http://www.111cn.net/phper/php/58174.htm
你可能感兴趣的文章
- phpexcel 生成excel代码
- php 利用phpexcel生成excel文档实例
- phpExcel类从mysql中将数据导出到xls乱码
- phpexcel读取excel文档代码
- 利用phpexcel读取excel实现代码
- phpexcel读写xls文件实现程序
- PHPExcel导出Excel文件时出现错误的解决办法
- PHPExcel用法详细的介绍
- phpExcel数据内存溢出解决办法
- PHPEXCEL的用法与简介
http://www.bkjia.com/PHPjc/738531.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/738531.htmlTechArticle代码如下 $dir = $DOCUMENT_ROOT.'/backoffice/admin/oemcheck/'; $templateName = '1.xlsx'; $outputFileName = '模板.xlsx'; $txt='test'; //实例化Excel读取类 $PHPReader = new...