public HttpResponseMessage Test() { var d = new RowNumModel <DoctorLearnViewModel>(); d.SearchParams = new DoctorLearnViewModel(); var ret = _iADDoctorService.GetDoctorLearn(d, true); var _filePath = HostingEnvironment.MapPath("/ExcelTemplate/" + "CatCityList.xlsx"); Workbook wb = new Workbook(_filePath); WorkbookDesigner book = new WorkbookDesigner(wb); book.SetDataSource("H", ret.Result); book.Process(); book.Workbook.Worksheets[0].Name = "222"; MemoryStream stream = new MemoryStream(); book.Workbook.Save(stream, SaveFormat.Xlsx); byte[] bytes = stream.ToArray(); var resp = new HttpResponseMessage(HttpStatusCode.OK) { Content = new ByteArrayContent(bytes) }; resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/x-excel"); resp.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName = $"{DateTime.Now.ToString("yyyyMMddHHmmsss")}{".xlsx"}" }; return(resp); }
public IHttpActionResult GetDoctorLearn(RowNumModel <DoctorLearnViewModel> rowNum) { var ret = _iADDoctorService.GetDoctorLearn(rowNum); return(Ok(ret)); }