...
|
...
|
@@ -279,6 +279,54 @@ class AdminEquipmentController extends AdminBaseController{ |
|
|
// END
|
|
|
}
|
|
|
|
|
|
//导出模板
|
|
|
public function template_export(){
|
|
|
|
|
|
$path = dirname(__FILE__); //找到当前脚本所在路径
|
|
|
vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/PHPExcel");
|
|
|
vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/PHPExcel/Writer/IWriter");
|
|
|
vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/PHPExcel/Writer/Abstract");
|
|
|
vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel5");
|
|
|
vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/PHPExcel/Writer/Excel2007");
|
|
|
vendor("VENDOR_PATH/phpoffice/phpexcel/Classes/IOFactory");
|
|
|
$objPHPExcel = new \PHPExcel();
|
|
|
$objWriter = new \PHPExcel_Writer_Excel5($objPHPExcel);
|
|
|
$objWriter = new \PHPExcel_Writer_Excel2007($objPHPExcel);
|
|
|
|
|
|
// 设置表头信息
|
|
|
$objPHPExcel->setActiveSheetIndex(0)
|
|
|
->setCellValue('A1', '设备锁编号')
|
|
|
->setCellValue('B1', '设备锁名称')
|
|
|
->setCellValue('C1', '二维码')
|
|
|
->setCellValue('D1', '初始医院')
|
|
|
->setCellValue('E1', 'MAC地址')
|
|
|
->setCellValue('F1', '备注');
|
|
|
|
|
|
/*--------------开始从数据库提取信息插入Excel表中------------------*/
|
|
|
|
|
|
// $i=2; //定义一个i变量,目的是在循环输出数据是控制行数
|
|
|
// $count = count($sql); //计算有多少条数据
|
|
|
// for ($i = 2; $i <= $count+1; $i++) {
|
|
|
// $objPHPExcel->getActiveSheet()->setCellValue('A' . $i, $sql[$i-2]['pname']);
|
|
|
// $objPHPExcel->getActiveSheet()->setCellValue('B' . $i, $sql[$i-2]['access']);
|
|
|
// $objPHPExcel->getActiveSheet()->setCellValue('C' . $i, $sql[$i-2]['jointime']);
|
|
|
// }
|
|
|
|
|
|
/*--------------下面是设置其他信息------------------*/
|
|
|
$objPHPExcel->getActiveSheet()->setTitle('sheet1'); //设置sheet的名称
|
|
|
$objPHPExcel->setActiveSheetIndex(0); //设置sheet的起始位置
|
|
|
|
|
|
header('Content-Disposition: attachment;filename="睡宝设备信息模板.xlsx"');
|
|
|
header('Content-Type: application/vnd.openxmlformats-officedocument.spreadsheetml.sheet');
|
|
|
header('Cache-Control: max-age=0');
|
|
|
$objWriter = \PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel5'); //通过PHPExcel_IOFactory的写函数将上面数据写出来
|
|
|
|
|
|
$PHPWriter = \PHPExcel_IOFactory::createWriter( $objPHPExcel,"Excel2007");
|
|
|
$PHPWriter->save("php://output"); //表示在$path路径下面生成demo.xlsx文件
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
//生成二维码
|
|
|
public function createQrCode($value){
|
|
|
import('phpqrcode.qrlib',VENDOR_PATH,'.php');
|
...
|
...
|
|