xuejianxiyang
[HttpGet]
        public IHttpActionResult ExportData()
        {
            
            ...
            var dt = ExcelHelper.ListToDataTable(list);
            var fileName = SysConfig.WebTempPath + Guid.NewGuid().ToString() + ".xls";
            ExcelHelper.ExportToFile(dt,fileName);
            
        //http://www.cnblogs.com/enternal/p/5417519.html HttpResponseMessage httpResponseMessage
= new HttpResponseMessage(HttpStatusCode.OK); FileStream fileStream = File.OpenRead(fileName); httpResponseMessage.Content = new StreamContent(fileStream); httpResponseMessage.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); httpResponseMessage.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment") { FileName =HttpUtility.UrlEncode(Path.GetFileName(fileName)) }; return ResponseMessage(httpResponseMessage); }

 

DF1E31DE-768E-43D7-B1DB-DE10BD031E13 From:http://www.cnblogs.com/xuejianxiyang/p/7802365.html

分类:

技术点:

相关文章:

  • 2022-01-10
  • 2022-12-23
  • 2022-12-23
  • 2021-07-16
  • 2022-12-23
  • 2022-12-23
  • 2021-10-19
  • 2021-11-11
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2021-12-23
  • 2021-11-03
  • 2021-08-15
  • 2021-09-10
相关资源
相似解决方案