public async Task <IActionResult> GetMaterialReceiveExcel(MaterialReceiveParam MaterialReceiveParam) { var data = await _reportService.GetMaterialReceiveExcel(MaterialReceiveParam); var path = Path.Combine(_webHostEnvironment.ContentRootPath, "Resources\\Template\\MaterialReceive.xlsx"); WorkbookDesigner designer = new WorkbookDesigner(); designer.Workbook = new Workbook(path); Worksheet ws = designer.Workbook.Worksheets[0]; designer.SetDataSource("result", data); designer.Process(); MemoryStream stream = new MemoryStream(); designer.Workbook.Save(stream, SaveFormat.Xlsx); byte[] result = stream.ToArray(); return(File(result, "application/xlsx", "Excel" + DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss") + ".xlsx")); }
public async Task <List <ReportMatRecExcel_Dto> > GetMaterialReceiveExcel(MaterialReceiveParam MaterialReceiveParam) { var data = await(_context.ReportMatRecExcel_Dto.FromSqlRaw("EXEC [dbo].[NSP_Receive_Material_Report] @DateType, @Date_S, @Date_E, @MO_No, @MO_Seq, @Supplier, @Status ,@Article", new SqlParameter("DateType", MaterialReceiveParam.DateType != 0 ? MaterialReceiveParam.DateType : (object)DBNull.Value), new SqlParameter("Date_S", MaterialReceiveParam.DateStart != "" ? MaterialReceiveParam.DateStart : (object)DBNull.Value), new SqlParameter("Date_E", MaterialReceiveParam.DateEnd != "" ? MaterialReceiveParam.DateEnd : (object)DBNull.Value), new SqlParameter("MO_No", MaterialReceiveParam.MoNo != "" ? MaterialReceiveParam.MoNo : (object)DBNull.Value), new SqlParameter("MO_Seq", MaterialReceiveParam.MoSeq != "" ? MaterialReceiveParam.MoSeq : (object)DBNull.Value), new SqlParameter("Supplier", (MaterialReceiveParam.Supplier != "" && MaterialReceiveParam.Supplier != "All") ? MaterialReceiveParam.Supplier : (object)DBNull.Value), new SqlParameter("Status", MaterialReceiveParam.Status), new SqlParameter("Article", MaterialReceiveParam.Article) )).ToListAsync(); data.ForEach(item => { if (item.Order_Status == "Y") { item.Order_Status = "Y.Close"; } else if (item.Order_Status == "D") { item.Order_Status = "D.Delete"; } else if (item.Order_Status == "C") { item.Order_Status = "C.Cancel"; } else if (item.Order_Status == "P") { item.Order_Status = "P.Partial"; } else { item.Order_Status = "Unship"; } }); return(data); }
public async Task <IActionResult> GetMaterialReceive(MaterialReceiveParam MaterialReceiveParam) { var data = await _reportService.GetMaterialReceiveExcel(MaterialReceiveParam); return(Ok(data)); }