public function exportStatisticsExcel($filename, $statistics_type, $selected_year) { $filename = $filename . ".xlsx"; $tmpfile = "uploads/{$filename}"; switch ($statistics_type) { case "statistics_summary_1": // 總表(依漁業別)>沿近海漁業統計資料 require_once 'includes/statistics/table_summary_1.class.php'; $table = new TableSummary1($selected_year); break; case "statistics_summary_2": // 總表(依漁業別)>魩鱙漁業統計資料 require_once 'includes/statistics/table_summary_2.class.php'; $table = new TableSummary2($selected_year); break; case "statistics_summary_3": // 總表(依漁業別)>燈火漁業統計資料 require_once 'includes/statistics/table_summary_3.class.php'; $table = new TableSummary3($selected_year); break; case "statistics_summary_4": // 總表(依漁業別)>燈火漁業統計資料 require_once 'includes/statistics/table_summary_4.class.php'; $table = new TableSummary4($selected_year); break; case "statistics_key_fishery_1": // 重點漁業管理>鯖鯵捕獲量分析 require_once 'includes/statistics/table_key_fishery_1.class.php'; $table = new TableKeyFishery1($selected_year); break; case "statistics_key_fishery_2": // 重點漁業管理>魩鱙漁獲量統計 require_once 'includes/statistics/table_key_fishery_2.class.php'; $table = new TableKeyFishery2($selected_year); break; } $excelWriter = $this->getPHPExcelObject(); $sheet = $excelWriter->getActiveSheet(); $table->exportExcel($excelWriter); /* pass by reference here */ $this->setBolderForAllSheet($sheet); $this->setAutoSizeForAllSheet($sheet); $objWriter = PHPExcel_IOFactory::createWriter($excelWriter, 'Excel2007'); $objWriter->save($tmpfile); header("Content-type:application/vnd.ms-excel;charset=UTF-8"); header("Content-Disposition: attachment; filename=\"{$filename}\""); header('Expires: 0'); header("Content-Length: " . filesize($tmpfile)); readfile($tmpfile); unlink($tmpfile); }
<?php $sqlCondition = " WHERE (fish_form_type_id >='3' AND fish_form_type_id <= '7') "; echo $utilsObj->m_optionObj->gen_fish_form_year_option($dbObj, $selected_year, $sqlCondition); ?> </select> <input type="button" name="btnQuery" id="btnQuery" value="送出查詢" /> </p> <p>重量(公斤) <input type="button" name="btnExport" id="btnExport" value="匯出excel" /> <input type="hidden" name="textYear" id="textYear" value="<?php echo $selected_year; ?> " /> <input type="hidden" name="textPage" id="textPage" value="<?php echo $_SERVER['SELF']; ?> " /> <input type="hidden" name="textType" id="textType" value="<?php echo "statistics_key_fishery_2"; ?> " /> <br /> </p> </div> <?php $table = new TableKeyFishery2($selected_year); $table->drawTable(); ?> <!--版權--> <?php require_once "footer.html";