### 选中的id js ``` function down(){ var selected_checkboxs = $('.table-responsive tbody tr td:first-child [type="checkbox"]:checked'); var goodsids = selected_checkboxs.map(function () { return $(this).val() }).get(); console.log(goodsids) window.location.href='/web/index.php?c=site&a=entry&m=ewei_shopv2&do=web&r=goods.down' } ``` ### 导出php ``` global $_W; global $_GPC; $id = $_GPC['id']; 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') ->setCellValue('C1', 'pcate') ->setCellValue('D1', 'ccate') ->setCellValue('E1', 'type') ->setCellValue('F1', 'status') ->setCellValue('G1', 'title') ->setCellValue('H1', 'thumb') ->setCellValue('I1', 'content') ->setCellValue('J1', 'productprice') ->setCellValue('K1', 'marketprice') ->setCellValue('L1', 'costprice') ->setCellValue('M1', 'originalprice') ->setCellValue('N1', 'total') ->setCellValue('O1', 'createtime') ->setCellValue('P1', 'weight') ->setCellValue('Q1', 'maxprice') ->setCellValue('R1', 'minprice') ->setCellValue('S1', 'cates') ->setCellValue('T1', 'hasoption') ->setCellValue('U1', 'thumb_url') ->setCellValue('V1', 'isverify') ->setCellValue('W1', 'tcate') ->setCellValue('X1', 'discounts') ->setCellValue('Y1', 'tcates') ->setCellValue('Z1', 'keywords'); $goods = pdo_fetchall("SELECT * FROM ".tablename('ewei_shop_goods')." WHERE id in (".$_GPC['id'].") "); foreach ($goods as $key => $value) { $l1="A".($key+2); $l2="B".($key+2); $l3="C".($key+2); $l4="D".($key+2); $l5="E".($key+2); $l6="F".($key+2); $l7="G".($key+2); $l8="H".($key+2); $l9="I".($key+2); $l10="J".($key+2); $l11="K".($key+2); $l12="L".($key+2); $l13="M".($key+2); $l14="N".($key+2); $l15="O".($key+2); $l16="P".($key+2); $l17="Q".($key+2); $l18="R".($key+2); $l19="S".($key+2); $l20="T".($key+2); $l21="U".($key+2); $l22="V".($key+2); $l23="W".($key+2); $l24="X".($key+2); $l25="Y".($key+2); $l26="Z".($key+2); $objPHPExcel ->setActiveSheetIndex(0) ->setCellValue($l1, $value['id']) ->setCellValue($l2, $value['uniacid']) ->setCellValue($l3, $value['pcate']) ->setCellValue($l4, $value['ccate']) ->setCellValue($l5, $value['type']) ->setCellValue($l6, $value['status']) ->setCellValue($l7, $value['title']) ->setCellValue($l8, $value['thumb']) ->setCellValue($l9, $value['content']) ->setCellValue($l10, $value['productprice']) ->setCellValue($l11, $value['marketprice']) ->setCellValue($l12, $value['costprice']) ->setCellValue($l13, $value['originalprice']) ->setCellValue($l14, $value['total']) ->setCellValue($l15, $value['createtime']) ->setCellValue($l16, $value['weight']) ->setCellValue($l17, $value['maxprice']) ->setCellValue($l18, $value['minprice']) ->setCellValue($l19, $value['cates']) ->setCellValue($l20, $value['hasoption']) ->setCellValue($l21, $value['thumb_url']) ->setCellValue($l22, $value['isverify']) ->setCellValue($l23, $value['tcate']) ->setCellValue($l24, $value['discounts']) ->setCellValue($l25, $value['tcates']) ->setCellValue($l26, $value['keywords']); } $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; ```