コード例 #1
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         var filePath = context.Server.MapPath(Settings.Default.GenericFilePath);
         if (!File.Exists(filePath))
         {
             return;
         }
         var excelStream      = File.OpenRead(filePath);
         var excelfile        = new GenericExcelFile(excelStream);
         var costCodes        = CreateCostCodes();
         var consumptionTypes = GenericHandler.Mappings.Select(pair => pair.Key);
         var package          = excelfile.CreatePackage(costCodes, consumptionTypes);
         var response         = context.Response;
         response.BinaryWrite(package.GetAsByteArray());
         response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
         response.AddHeader("content-disposition",
                            "attachment;  filename=" + Settings.Default.GenericDownloadName);
     }
     catch (Exception ex)
     {
         ExceptionPolicy.HandleException(ex, ExceptionPolicyName);
     }
 }
コード例 #2
0
 public void ProcessRequest(HttpContext context)
 {
     try
     {
         var filePath = context.Server.MapPath(Settings.Default.GenericFilePath);
         if (!File.Exists(filePath)) return;
         var excelStream = File.OpenRead(filePath);
         var excelfile = new GenericExcelFile(excelStream);
         var costCodes = CreateCostCodes();
         var consumptionTypes = GenericHandler.Mappings.Select(pair => pair.Key);
         var package = excelfile.CreatePackage(costCodes, consumptionTypes);
         var response = context.Response;
         response.BinaryWrite(package.GetAsByteArray());
         response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
         response.AddHeader("content-disposition",
                            "attachment;  filename=" + Settings.Default.GenericDownloadName);
     }
     catch (Exception ex)
     {
         ExceptionPolicy.HandleException(ex, ExceptionPolicyName);
     }
 }