Advertisement
Guest User

Untitled

a guest
Jul 31st, 2015
219
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.36 KB | None | 0 0
  1. string strPath = Constant.GetCustomerAtStore;
  2. string strFileName = Server.MapPath(strPath);
  3.  
  4. if (!File.Exists(strFileName))
  5. {
  6. SiteMaster.ET = "Không tìm thấy file " + strFileName;
  7. return;
  8. }
  9.  
  10. strFileName = MKTDBO.CreateExcel_GetCustomerAtStore(strFileName, MKTDTO);
  11.  
  12. }
  13. catch (Exception ex)
  14. {
  15. throw new Exception(ex.Message);
  16. }
  17. }
  18. private void SaveFileExcel(string strFileName)
  19. {
  20. try
  21. {
  22.  
  23. //Save file dialog trong thư mục download
  24. FileInfo file = new FileInfo(strFileName);
  25.  
  26. long sz = file.Length;
  27.  
  28. Response.ClearContent();
  29. Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
  30. Response.AddHeader("Content-Disposition", string.Format("attachment; filename = {0}", System.IO.Path.GetFileName(strFileName)));
  31. Response.AddHeader("Content-Length", sz.ToString("F0"));
  32. Response.TransmitFile(strFileName);
  33.  
  34. // Response.End();
  35. HttpContext.Current.ApplicationInstance.CompleteRequest();
  36. }
  37. catch (Exception ex)
  38. {
  39. throw new Exception(ex.Message);
  40. }
  41. finally {
  42. SiteMaster.ET = "SUCCESS!!";//show string
  43.  
  44. }
  45. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement