正在显示
1 个修改的文件
包含
48 行增加
和
0 行删除
@@ -279,6 +279,54 @@ class AdminEquipmentController extends AdminBaseController{ | @@ -279,6 +279,54 @@ class AdminEquipmentController extends AdminBaseController{ | ||
279 | // END | 279 | // END |
280 | } | 280 | } |
281 | 281 | ||
282 | + //导出模板 | ||
283 | + public function template_export(){ | ||
284 | + | ||
285 | + $path = dirname(__FILE__); //找到当前脚本所在路径 | ||
286 | + vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/PHPExcel"); | ||
287 | + vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/PHPExcel/Writer/IWriter"); | ||
288 | + vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/PHPExcel/Writer/Abstract"); | ||
289 | + vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5"); | ||
290 | + vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007"); | ||
291 | + vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/IOFactory"); | ||
292 | + $objPHPExcel = new \PHPExcel(); | ||
293 | + $objWriter = new \PHPExcel_Writer_Excel5($objPHPExcel); | ||
294 | + $objWriter = new \PHPExcel_Writer_Excel2007($objPHPExcel); | ||
295 | + | ||
296 | + // 设置表头信息 | ||
297 | + $objPHPExcel->setActiveSheetIndex(0) | ||
298 | + ->setCellValue('A1', '设备锁编号') | ||
299 | + ->setCellValue('B1', '设备锁名称') | ||
300 | + ->setCellValue('C1', '二维码') | ||
301 | + ->setCellValue('D1', '初始医院') | ||
302 | + ->setCellValue('E1', 'MAC地址') | ||
303 | + ->setCellValue('F1', '备注'); | ||
304 | + | ||
305 | + /*--------------开始从数据库提取信息插入Excel表中------------------*/ | ||
306 | + | ||
307 | +// $i=2; //定义一个i变量,目的是在循环输出数据是控制行数 | ||
308 | +// $count = count($sql); //计算有多少条数据 | ||
309 | +// for ($i = 2; $i <= $count+1; $i++) { | ||
310 | +// $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $sql[$i-2]['pname']); | ||
311 | +// $objPHPExcel->getActiveSheet()->setCellValue('B' . $i, $sql[$i-2]['access']); | ||
312 | +// $objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $sql[$i-2]['jointime']); | ||
313 | +// } | ||
314 | + | ||
315 | + /*--------------下面是设置其他信息------------------*/ | ||
316 | + $objPHPExcel->getActiveSheet()->setTitle('sheet1'); //设置sheet的名称 | ||
317 | + $objPHPExcel->setActiveSheetIndex(0); //设置sheet的起始位置 | ||
318 | + | ||
319 | + header('Content-Disposition: attachment;filename="睡宝设备信息模板.xlsx"'); | ||
320 | + header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet'); | ||
321 | + header('Cache-Control: max-age=0'); | ||
322 | + $objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); //通过PHPExcel_IOFactory的写函数将上面数据写出来 | ||
323 | + | ||
324 | + $PHPWriter = \PHPExcel_IOFactory::createWriter( $objPHPExcel,"Excel2007"); | ||
325 | + $PHPWriter->save("php://output"); //表示在$path路径下面生成demo.xlsx文件 | ||
326 | + | ||
327 | + } | ||
328 | + | ||
329 | + | ||
282 | //生成二维码 | 330 | //生成二维码 |
283 | public function createQrCode($value){ | 331 | public function createQrCode($value){ |
284 | import('phpqrcode.qrlib',VENDOR_PATH,'.php'); | 332 | import('phpqrcode.qrlib',VENDOR_PATH,'.php'); |
-
请 注册 或 登录 后发表评论