Copy CodeThe code is as follows:
Template Storage Directory
$dir = $DOCUMENT _root. ' /backoffice/admin/oemcheck/';
$templateName = ' 1.xlsx ';
$outputFileName = ' template. xlsx ';
$txt = ' Test ';
Instantiating an Excel Read 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;
}
}
Read Excel
$PHPExcel = $PHPReader->load ($dir. $templateName);
Reading sheet 1
$currentSheet = $PHPExcel->getsheet (0);
$currentSheet->setcellvalue (' B13 ', iconv (' GBK ', ' utf-8 ', $txt));//table header assignment//
Instantiating an 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 ');
http://www.bkjia.com/PHPjc/736841.html www.bkjia.com true http://www.bkjia.com/PHPjc/736841.html techarticle Copy the code as follows://template storage Directory $dir = $DOCUMENT _root. ' /backoffice/admin/oemcheck/'; $templateName = ' 1.xlsx '; $outputFileName = ' template. xlsx '; $txt = ' Test '; Instantiate ...