/// <summary> /// 產生Excel byte[] /// </summary> /// <typeparam name="T"></typeparam> /// <param name="pList"></param> /// <param name="em"></param> /// <returns></returns> public byte[] exportExcel(DataTable dt, ExcelSetting em, bool exportFile = false) { byte[] buf = null; string actionName = "exportExcel"; setFileContentType(fileType.xls); try { NPOITool NPOITool = new Models.NPOITool(); if (em.isSetbindColName) { buf = NPOITool.ExportExcelTable(dt, em.titleName, this.FileDownloadName, em.sheetName, em.bindColName, em.colTitleName, em.exportActionName); } else { buf = NPOITool.ExportExcelTable(dt, em.titleName, em.sheetName, em.titleName, @showColname: true); } buf = buf == null ? new byte[0] : buf; } catch (Exception ex) { RESPONSE_MSG.message = "產生Excel發生錯誤,請洽資訊人員,錯誤訊息如下所示:" + ex.Message; RESPONSE_MSG.status = RESPONSE_STATUS.EXCEPTION; LogTool.SaveLogMessage(ex, actionName, csName); } return(buf); }
/// <summary> /// 產生交班表Excel byte[] /// </summary> /// <param name="sch_data"></param> /// <returns></returns> public FileContentResult ExportShiftExcel(scheduling sch_data) { byte[] buf = null; string actionName = "ExportShiftExcel"; setFileContentType(fileType.xls); try { NPOITool NPOITool = new Models.NPOITool(); buf = NPOITool.ExportShiftExcel(sch_data); } catch (Exception ex) { RESPONSE_MSG.message = "產生Excel發生錯誤,請洽資訊人員,錯誤訊息如下所示:" + ex.Message; RESPONSE_MSG.status = RESPONSE_STATUS.EXCEPTION; LogTool.SaveLogMessage(ex, actionName, csName); } return(retunFile(buf)); }