ecshop订单倒出excel格式
2013-01-06 00:21 来源:www.chinab4c.com 作者:ecshop专家
ecshop订单倒出excel格式,这个是十分方便的。我们在处理ecshop订单倒出的时候,就会遇到这个问题。ecshop二次开发常常需要使用倒出各种各样的excel格式。我们结合以下例子,谈谈对ecshop订单倒出excel格式分析。
$order_list = compute_order($start_date, $bution_id);
require_once ROOT_PATH.'includes/PHPExcel/PHPExcel.php';
/** PHPExcel_IOFactory */
require_once ROOT_PATH.'includes/PHPExcel/PHPExcel/IOFactory.php';
// Create new PHPExcel object
$objPHPExcel = new PHPExcel();
// Set properties
$objPHPExcel->getProperties()->setCreator("DizzyLion")
->setLastModifiedBy("DizzyLion")
->setSubject("Orders output Document");
phpexcelfromdata(&$objPHPExcel,$order_list['order_list']);
$filepaths= ROOT_PATH."temp/xls/".$_SERVER['SERVER_NAME'].'_Orders_'.date("Y-m-d_H_i").'.xls';
$filename = $_SERVER['SERVER_NAME'].'_Orders_'.date("Y-m-d_H_i").'.xls';
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->setTempDir(ROOT_PATH."temp");
$objWriter->save($filepaths);
header("Location:../temp/xls/".$filename);
以下是处理的函数,将ecshop数据库数据,写到excel格式中去。
function phpexcelfromdata(&$objExcel,$sum_array){
global $_LANG;
$rowix = 1;
$objExcel->setActiveSheetIndex(0)
->setCellValue('A'.$rowix , '订单id')
->setCellValue('B'.$rowix , '用户电话')
->setCellValue('C'.$rowix , '付费id')
->setCellValue('D'.$rowix , '订单金额')
->setCellValue('E'.$rowix , '余额支付')
->setCellValue('F'.$rowix , '金额支付')
->setCellValue('G'.$rowix , '出货金额')
->setCellValue('H'.$rowix , '应收货款')
->setCellValue('I'.$rowix , '用户地址')
->setCellValue('J'.$rowix , '最佳时间')
->setCellValue('K'.$rowix , '订单留言');
$objExcel->setActiveSheetIndex(0)->getStyle("A$rowix:I$rowix")->applyFromArray(
array(
'fill' => array(
'type' => PHPExcel_Style_Fill::FILL_SOLID,
'startcolor' => array('argb' => 'FFCCCCCC'),
'endcolor' => array('argb' => 'FFCCCCCC')
)
)
);
$rowix++;
$i=0;
foreach ($sum_array as $key => $value) {
$objExcel->setActiveSheetIndex(0)
->setCellValue('A'.$rowix , $value['order_sn'])
->setCellValue('B'.$rowix , $value['mobile'])
->setCellValue('C'.$rowix , $value['pay_id'])
->setCellValue('D'.$rowix , $value['order_paid_sum'])
->setCellValue('E'.$rowix , $value['surplus'])
->setCellValue('F'.$rowix , $value['money_paid'])//采购价
->setCellValue('G'.$rowix , $value['paid_sum'])
->setCellValue('H'.$rowix , $value['should_pay'])//一份价格
->setCellValue('I'.$rowix , $value['address'])
->setCellValue('J'.$rowix , $value['best_time'])
->setCellValue('K'.$rowix , $value['how_oos'])
;
$rowix++;
}
$objExcel->setActiveSheetIndex(0)->getColumnDimension('A')->setAutoSize(true);
$objExcel->setActiveSheetIndex(0)->getColumnDimension('B')->setAutoSize(true);
$objExcel->setActiveSheetIndex(0)->getColumnDimension('C')->setAutoSize(true);
$objExcel->setActiveSheetIndex(0)->getColumnDimension('D')->setAutoSize(true);
$objExcel->setActiveSheetIndex(0)->getColumnDimension('E')->setAutoSize(true);
$objExcel->setActiveSheetIndex(0)->getColumnDimension('F')->setAutoSize(true);
$objExcel->setActiveSheetIndex(0)->getColumnDimension('G')->setAutoSize(true);
$objExcel->setActiveSheetIndex(0)->getColumnDimension('H')->setAutoSize(true);
$objExcel->setActiveSheetIndex(0)->getColumnDimension('I')->setAutoSize(true);
$objExcel->setActiveSheetIndex(0)->getColumnDimension('J')->setAutoSize(true);
$objExcel->setActiveSheetIndex(0)->getColumnDimension('K')->setAutoSize(true);
$objExcel->setActiveSheetIndex(0);
}
来源:http://www.chinab4c.com
最近更新
常用插件
- ecshop分类树中统计商品数
最近忙于开发其他项目,在不少朋友不断要求和催促的情况下,做出了该小...
- ecshop降价通知登记插件
ecshop降价通知登记插件,主要是为了方便某些客户,对商品价格要求比...
- ecshop通用红包编码
很多时候,为了结合促销,必须扩展一下ecshop的红包功能。ecshop的红包...
- ecshop红包修改成满多少减
我们在长期使用ecshop的时候,我们可以发现。ecshop的红包是一个非常强...
- ecshop购物车功能改进[插件
ecshop购物车功能改进[插件套餐]主要是我们最近开发工作和开发项目中。...