php导出excel最简单的办法,无需phpexcel
Posted afterrains
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了php导出excel最简单的办法,无需phpexcel相关的知识,希望对你有一定的参考价值。
public function exportDayInner()
$start_date = input('start');
$end_date = input('end');
$innerdata = Db::table('inner')
->whereTime('add_date', 'between', [$start_date,$end_date])
->where('inner.depart_id',session('depart_id'))
->join('goods','inner.goods_id = goods.id')
->join('storage','storage.id = inner.storage_id')
->join('supplier','supplier.id = inner.supplier_id')
->join('user','user.id = inner.user_id')
//->limit(5)
->order('inner.id desc')
->field('goods_name,add_date,storage_name,supplier_name,real_name,num,inner.price')
->select();
$table = '';
$table .= "<table>
<thead>
<tr>
<th class='name'>名称</th>
<th class='name'>入库日期</th>
<th class='name'>入库库位</th>
<th class='name'>供货商</th>
<th class='name'>入库人</th>
<th class='name'>数量</th>
<th class='name'>单价</th>
</tr>
</thead>
<tbody>";
foreach ($innerdata as $v)
$table .= "<tr>
<td class='name'>$v['goods_name']</td>
<td class='name'>$v['add_date']</td>
<td class='name'>$v['storage_name']</td>
<td class='name'>$v['supplier_name']</td>
<td class='name'>$v['real_name']</td>
<td class='name'>$v['num']</td>
<td class='name'>$v['price']</td>
</tr>";
$table .= "</tbody>
</table>";
//通过header头控制输出excel表格
header("Pragma: public");
header("Expires: 0");
header("Cache-Control:must-revalidate, post-check=0, pre-check=0");
header("Content-Type:application/force-download");
header("Content-Type:application/vnd.ms-execl");
header("Content-Type:application/octet-stream");
header("Content-Type:application/download");;
header('Content-Disposition:attachment;filename="入库明细表.xls"');
header("Content-Transfer-Encoding:binary");
echo $table;
http://www.cankaojishu.com/
以上是关于php导出excel最简单的办法,无需phpexcel的主要内容,如果未能解决你的问题,请参考以下文章
使用 php excel 导出到 excel 到最直接的工作表