模板下载功能添加

master
zhengyongxing 4 years ago
parent 07ee17ca1d
commit 9fceedd10e

@ -104,6 +104,9 @@
<button class="submit_btn" id="submit_btn">
保存
</button>
<a class="submit_btn " alt="下载模板" title="下载模板" href="{:U('downloadCoefficient')}">
下载模板
</a>
<a class="submit_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();">
返回
</a>

@ -534,4 +534,32 @@ class ExcelPaymentController extends BaseController
}
//模板导出
public function downloadTemplate()
{
header("Content-type: text/html; charset=utf-8");
error_reporting(E_ALL);
ini_set('display_errors', TRUE);
ini_set('display_startup_errors', TRUE);
define('EOL',(PHP_SAPI == 'cli') ? PHP_EOL : '<br />');
Vendor("PHPExcel.PHPExcel");
$objPHPExcel = new \PHPExcel();
$objReader = \PHPExcel_IOFactory::createReader('Excel2007');
//设置模板文件
$objPHPExcel = $objReader->load("Public/Admin/excel/underPayment.xlsx");
$fileName = "线下打款导入模板";
ob_end_clean();//清除缓冲区,避免乱码
header('pragma:public');
header('Content-type:application/vnd.ms-excel;charset=utf-8;name="' . $fileName .'".xls');
header("Content-Disposition:attachment;filename={$fileName}.xls");//attachment新窗口打印inline本窗口打印
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;
}
}

@ -53,6 +53,9 @@
<button class="submit_btn" id="submit_btn">
保存
</button>
<a class="submit_btn " alt="下载模板" title="下载模板" href="{:U('downloadTemplate')}">
下载模板
</a>
<a class="submit_btn " alt="返回上一页" title="返回上一页" href="javascript:window.history.back();">
返回
</a>

Loading…
Cancel
Save