/// <summary> /// 下載 Excel /// </summary> /// <param name="type">(A72.A73)</param> /// <param name="path">下載位置</param> /// <returns></returns> public MSGReturnModel DownLoadExcel(string type, string path) { MSGReturnModel result = new MSGReturnModel(); result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.download_Fail .GetDescription(type, Message_Type.not_Find_Any.GetDescription()); if (db.Moody_Tm_YYYY.Any()) { DataTable datas = getExhibit29ModelFromDb(db.Moody_Tm_YYYY.ToList()).Item1; if (Excel_DownloadName.A72.ToString().Equals(type)) { result.DESCRIPTION = FileRelated.DataTableToExcel(datas, path, Excel_DownloadName.A72); result.RETURN_FLAG = string.IsNullOrWhiteSpace(result.DESCRIPTION); } if (Excel_DownloadName.A73.ToString().Equals(type)) { DataTable newData = FromA72GetA73(datas); //要組新的 Table if (newData != null) //有資料 { result.DESCRIPTION = FileRelated.DataTableToExcel(newData, path, Excel_DownloadName.A73); result.RETURN_FLAG = string.IsNullOrWhiteSpace(result.DESCRIPTION); } else { result.DESCRIPTION = Message_Type.download_Fail.GetDescription(type, Message_Type.not_Find_Any.GetDescription()); } } if (result.RETURN_FLAG) { result.DESCRIPTION = Message_Type.download_Success.GetDescription(type); } } return(result); }
/// <summary> /// 下載 Excel /// </summary> /// <param name="type">(A59)</param> /// <param name="path">下載位置</param> /// <param name="cache">cache 資料</param> /// <returns></returns> public MSGReturnModel DownLoadExcel <T>(string type, string path, List <T> data) { MSGReturnModel result = new MSGReturnModel(); result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.download_Fail .GetDescription(type, Message_Type.not_Find_Any.GetDescription()); if (Excel_DownloadName.A59.ToString().Equals(type)) { List <A58ViewModel> A58Data = data.Cast <A58ViewModel>().ToList(); DataTable dt = A58Data.Select(x => getA59ViewModel(x)).ToList().ToDataTable(); result.DESCRIPTION = FileRelated.DataTableToExcel(dt, path, Excel_DownloadName.A59); result.RETURN_FLAG = string.IsNullOrWhiteSpace(result.DESCRIPTION); } return(result); }
/// <summary> /// 下載 Excel /// </summary> /// <typeparam name="T"></typeparam> /// <param name="type"></param> /// <param name="path"></param> /// <param name="data"></param> /// <returns></returns> public MSGReturnModel DownLoadExcel <T>(Excel_DownloadName type, string path, List <T> data) { MSGReturnModel result = new MSGReturnModel(); result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.download_Fail .GetDescription(null, Message_Type.not_Find_Any.GetDescription()); if (type == Excel_DownloadName.A95_1) { result.DESCRIPTION = FileRelated.DataTableToExcel(data.Cast <A95_1ViewModel>().ToList().ToDataTable(), path, Excel_DownloadName.A95_1, new A95_1ViewModel().GetFormateTitles()); result.RETURN_FLAG = string.IsNullOrWhiteSpace(result.DESCRIPTION); } if (type == Excel_DownloadName.A96) { result.DESCRIPTION = FileRelated.DataTableToExcel(data.Cast <A96ViewModel>().ToList().ToDataTable(), path, Excel_DownloadName.A96); result.RETURN_FLAG = string.IsNullOrWhiteSpace(result.DESCRIPTION); } return(result); }
public MSGReturnModel DownLoadA62Excel(string path, List <A62ViewModel> dbDatas) { MSGReturnModel result = new MSGReturnModel(); result.RETURN_FLAG = false; result.DESCRIPTION = Message_Type.download_Fail.GetDescription(); if (dbDatas.Any()) { DataTable datas = getA62ModelFromDb(dbDatas).Item1; result.DESCRIPTION = FileRelated.DataTableToExcel(datas, path, Excel_DownloadName.A62); result.RETURN_FLAG = string.IsNullOrWhiteSpace(result.DESCRIPTION); if (result.RETURN_FLAG) { result.DESCRIPTION = Message_Type.download_Success.GetDescription(); } } return(result); }