phpexcel 导入导出(已解决获取不到AA列之后内容)
本人使用tp框架,单独写了导入导出公共文件
导入上传文件
html
<input type="file" name="file"/>
<input type="button" id="upExcel" value="导入Excel" />
$('#upExcel').click(function(){
$('#searchform').submit();
});
提交PHP页面
public $excel;
public function __construct()
{
parent::__construct();
$this->excel = new ExcelController();
}
(form指向的文件)
$upload = new Upload();
$upload->maxSize = 3145728 ;// 设置附件上传大小
$upload->exts = array('xls', 'xlsx');// 设置附件上传类
$upload->savePath = '/hxrc/Public/Uploads/'; // 设置附件上传目录
// 上传文件
$info = $upload->uploadOne($_FILES['file']);
$filename = './Uploads/'.$info['savepath'].$info['savename'];
$exts = $info['ext'];
if(!$info) {
// 上传错误提示错误信息
$this->error($upload->getError());
}else{
// 上传成功
$this->excel->import_excel($filename, $exts);
}
导出下载文件
html
<input type="button" id="downExcel" value="下载用户信息"/>
$('#downExcel').click(