首页 新闻 会员 周边 捐助

求教各位大神,php导出excel文档,上下各有一行空数据,怎么解决???

0
[已关闭问题] 关闭于 2017-12-08 11:51

如图这样的,上面是因为有表头占用了  关键是红框区域怎么去掉呢?求教坛子里的各位大神了

//引入PHPExcel类库
include(ROOT_PATH ."/includes/libraries/PHPExcel.php");
include(ROOT_PATH ."/includes/libraries/PHPExcel/IOFactory.php");

//new一个excel对象
$objPHPExcel = new PHPExcel();

/*以下是一些设置 ,什么作者 标题啊之类的*/
$objPHPExcel->getProperties()->setCreator("admin")
->setLastModifiedBy("refund_data")
->setTitle("退款数据导出")
->setSubject("退款数据导出")
->setDescription("退款数据导出")
->setKeywords("excel")
->setCategory("result file");
$new_refunds=array_values($refunds);

// 表头
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', '下单时间')
->setCellValue('B1', '退款时间')
->setCellValue('C1', '订单编号')
->setCellValue('D1', '仓库')
->setCellValue('E1', '商品名称')
->setCellValue('F1', '规格')
->setCellValue('G1', 'SKU编码')
->setCellValue('H1', '数量')
->setCellValue('I1', '单价')
->setCellValue('J1', '商品总价')
->setCellValue('K1', '折扣')
->setCellValue('L1', '运费')
->setCellValue('M1', '订单总价')
->setCellValue('N1', '是否开票')
->setCellValue('O1', '开票金额')
->setCellValue('P1', '退款编号');


foreach($new_refunds as $k => $v){
//从1开始
$num=$k+2;

//设置活动工作簿
$objPHPExcel->setActiveSheetIndex(0)

//Excel的第A列,下面以此类推
->setCellValue('A'.$num, local_date('Y-m-d H:i:s', $v['add_time'])) //A1 A2
->setCellValue('B'.$num, $v['end_time']?local_date('Y-m-d H:i:s', $v['end_time']):'')
->setCellValue('C'.$num, $v['order_sn'])
->setCellValue('D'.$num, $v['storage_id'])
->setCellValue('E'.$num, $v['goods_name'])
->setCellValue('F'.$num, $v['specification'])
->setCellValue('G'.$num, $v['sku'])
->setCellValue('H'.$num, -$v['quantity'])
->setCellValue('I'.$num, $v['price'])
->setCellValue('J'.$num, -$v['goods_amount'])
->setCellValue('K'.$num, $v['discount'])
->setCellValue('L'.$num, -$v['refund_shipping_fee'])
->setCellValue('M'.$num, $v['order_amount'])
->setCellValue('N'.$num, $this->get_invoice_type($v['invoice_type']))
->setCellValue('O'.$num, $v['order_amount'])
->setCellValue('P'.$num, " ".$v['refund_sn'])
;
}
//设置活动工作簿的标题
$objPHPExcel->getActiveSheet()->setTitle('refund');
//设置当前工作簿为第一个工作簿
$objPHPExcel->setActiveSheetIndex(0);
//以文件下载的方式输出
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="refund'.date('Y-m-d').'.xls"');
header('Cache-Control: max-age=0');
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;

上述是我的代码
Mercedes-Benz-G63的主页 Mercedes-Benz-G63 | 菜鸟二级 | 园豆:208
提问于:2017-09-06 15:18
< >
分享
所有回答(1)
1

你的问题解决了吗

不断成长 | 园豆:202 (菜鸟二级) | 2018-01-19 16:26
清除回答草稿
   您需要登录以后才能回答,未注册用户请先注册