diff --git a/application/rongyu/controller/DwRongyu.php b/application/rongyu/controller/DwRongyu.php index bd99724d..54f00694 100644 --- a/application/rongyu/controller/DwRongyu.php +++ b/application/rongyu/controller/DwRongyu.php @@ -343,4 +343,7 @@ class DwRongyu extends Base return json($data); } + + + } diff --git a/application/rongyu/controller/JsRongyuInfo.php b/application/rongyu/controller/JsRongyuInfo.php index 99dc45df..d3ac3a81 100644 --- a/application/rongyu/controller/JsRongyuInfo.php +++ b/application/rongyu/controller/JsRongyuInfo.php @@ -7,6 +7,11 @@ use app\common\controller\Base; // 引用教师数据模型类 use app\rongyu\model\JsRongyuInfo as ryinfo; +// 引用PhpSpreadsheet类 +use PhpOffice\PhpSpreadsheet\Spreadsheet; +use PhpOffice\PhpSpreadsheet\Writer\Xlsx; +use PhpOffice\PhpSpreadsheet\IOFactory; + class JsRongyuInfo extends Base { /** @@ -400,4 +405,21 @@ class JsRongyuInfo extends Base // 返回信息 return json($data); } + + // 下载荣誉信息 + public function outXlsx($id) + { + + //通过工厂模式创建内容 + $spreadsheet = \PhpOffice\PhpSpreadsheet\IOFactory::load('jsRongyu.xlsx'); + + $worksheet = $spreadsheet->getActiveSheet(); + + $worksheet->getCell('A1')->setValue('John'); + $worksheet->getCell('A2')->setValue('Smith'); + //通过工厂模式来写内容 + $writer = \PhpOffice\PhpSpreadsheet\IOFactory::createWriter($spreadsheet, 'Xls'); + $writer->save('write.xls');; + + } } diff --git a/public/jsRongyu.xlsx b/public/jsRongyu.xlsx new file mode 100644 index 00000000..ccb3b7de Binary files /dev/null and b/public/jsRongyu.xlsx differ diff --git a/public/write.xls b/public/write.xls new file mode 100644 index 00000000..2363cf6f Binary files /dev/null and b/public/write.xls differ