public async Task <ActionResult> ExportExcelScoreRecordDetail(string recordId) { var data = await _auditRateService.GetScoreRecoreDetail(recordId); var Building = await _auditPicDService.GetBuildingByID(data.auditRateM.Building); var path = Path.Combine(_webHostEnvironment.ContentRootPath, "Resource\\Template\\Sixs_Score_Record_Detail_Template.xlsx"); WorkbookDesigner designer = new WorkbookDesigner(); designer.Workbook = new Workbook(); Worksheet ws = designer.Workbook.Worksheets[0]; // Gan gia tri tinh ws.Cells["B2"].PutValue(data.auditRateM.Record_Date); ws.Cells["D2"].PutValue(data.auditRateM.PDC); ws.Cells["F2"].PutValue(Building); ws.Cells["B3"].PutValue(data.auditRateM.Updated_By); ws.Cells["D3"].PutValue(data.auditRateM.Updated_Time); ws.Cells["F3"].PutValue(data.auditRateM.Line_ID_2_Name); ws.Cells["F4"].PutValue(data.auditRateM.Audit_Type2); designer.SetDataSource("result", data.listAuditRateD); designer.Process(); MemoryStream stream = new MemoryStream(); designer.Workbook.Save(stream, SaveFormat.Xlsx); byte[] result = stream.ToArray(); return(File(result, "application/xlsx", "Sixs_Score_Record_Detail" + DateTime.Now.ToString("dd_MM_yyyy_HH_mm_ss"))); }
public async Task <IActionResult> GetScoreRecordDetail(string recordId) { var data = await _auditRateService.GetScoreRecoreDetail(recordId); if (data != null) { return(Ok(data)); } return(NoContent()); }