php怎么导出大量数据的Excel
12个回答
展开全部
视图
<a href="brand.php?action=Export&searchKey=<?php echo $params['key'] ?>">导出EXECL</a>
控制器
function Export() {
$this->cplimitmodel->check('brand_export');
$this->load->library('excelwriter');
$keywords = $this->input->get('keywords');
$excelWriter = new ExcelWriter();
$where = "1=1";
$excelContent = array();
if ($keywords)
$where[] = "name like '%{$keywords}%'";
$orderBy = 'id DESC';
$where = implode(' and ', $where);
$dataList = $this->brandmodel->getList($where);
foreach ($dataList as $key => $t) {
$excelContent[] = array(
'name' => $t['name'],
);
}
$excelWriter->download('品牌导出表', array(
'name' => '品牌名称'
), $excelContent);
}
模型
function check($point, $msgButton=true){
$limit = $this->getLoginLimit();
$caller = $this->input->getPost('caller');
if(!$limit){
if($caller == 'ajax')
$this->message->response(false, '没有找到权限点');
else
$this->message->cpError('没有找到权限点', $msgButton);
}
if(!in_array('admin_allowall', $limit)){
if(!in_array($point, $limit)){
if($caller == 'ajax')
$this->message->response(false, '没有权限操作此功能,缺少 ' . $point . ' 权限');
else
$this->message->cpError('没有权限操作此功能,缺少 ' . $point . ' 权限', $msgButton);
}
}
<a href="brand.php?action=Export&searchKey=<?php echo $params['key'] ?>">导出EXECL</a>
控制器
function Export() {
$this->cplimitmodel->check('brand_export');
$this->load->library('excelwriter');
$keywords = $this->input->get('keywords');
$excelWriter = new ExcelWriter();
$where = "1=1";
$excelContent = array();
if ($keywords)
$where[] = "name like '%{$keywords}%'";
$orderBy = 'id DESC';
$where = implode(' and ', $where);
$dataList = $this->brandmodel->getList($where);
foreach ($dataList as $key => $t) {
$excelContent[] = array(
'name' => $t['name'],
);
}
$excelWriter->download('品牌导出表', array(
'name' => '品牌名称'
), $excelContent);
}
模型
function check($point, $msgButton=true){
$limit = $this->getLoginLimit();
$caller = $this->input->getPost('caller');
if(!$limit){
if($caller == 'ajax')
$this->message->response(false, '没有找到权限点');
else
$this->message->cpError('没有找到权限点', $msgButton);
}
if(!in_array('admin_allowall', $limit)){
if(!in_array($point, $limit)){
if($caller == 'ajax')
$this->message->response(false, '没有权限操作此功能,缺少 ' . $point . ' 权限');
else
$this->message->cpError('没有权限操作此功能,缺少 ' . $point . ' 权限', $msgButton);
}
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
用第三方类库,比如PHPexcel
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询