global $_W;
global $_GPC;
$sql = 'SELECT * FROM ' . tablename('ewei_shop_minhua_jiang') . ' ';
$list = pdo_fetchall($sql);
require_once IA_ROOT . '/framework/library/phpexcel/PHPExcel.php';
require_once IA_ROOT . '/framework/library/phpexcel/PHPExcel/Writer/Excel5.php';
$objPHPExcel = new PHPExcel();
$objPHPExcel->getProperties()->setCreator("Phpmarker")->setLastModifiedBy("Phpmarker")->settitle("Phpmarker")->setSubject("Phpmarker")->setDescription("Phpmarker")->setKeywords("Phpmarker")->setCategory("Phpmarker");
$objPHPExcel->getActiveSheet()->settitle('Phpmarker-' . date('Y-m-d'));
// Set active sheet index to the first sheet, so Excel opens this as the first sheet
$objPHPExcel->setActiveSheetIndex(0);
$objPHPExcel->getActiveSheet()->getDefaultRowDimension()->setRowHeight(15);
$objPHPExcel->getActiveSheet()->freezePane('A10');
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue('A1', 'id')
->setCellValue('B1', 'uniacid');
foreach ($list as $key => $value) {
$l1="A".($key+2); //循环 显示到 哪些行上面
$l2="B".($key+2);
$objPHPExcel->setActiveSheetIndex(0)
->setCellValue($l1, $value['id'])
->setCellValue($l2, $value['uniacid']);
}
$objPHPExcel->getActiveSheet()->setTitle('商品'.date("m-d",time()));
$objPHPExcel->setActiveSheetIndex(0);
$filename='商品'.date("m-d",time());
// Redirect output to a client’s web browser (Excel5)
header('Content-Type: application/vnd.ms-excel');
header('Content-Disposition: attachment;filename="'.$filename.'.xls"');
header('Cache-Control: max-age=0');
// If you're serving to IE 9, then the following may be needed
header('Cache-Control: max-age=1');
// If you're serving to IE over SSL, then the following may be needed
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT'); // Date in the past
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT'); // always modified
header('Cache-Control: cache, must-revalidate'); // HTTP/1.1
header('Pragma: public'); // HTTP/1.0
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5');
$objWriter->save('php://output');
exit;