title: Create Excel using EPPlus and save it on server folder
body: <p>I want to create an Excel file using EPPlus and save it to a folder on server.</p>
  
  <pre><code>DataTable dt_final = get_gridview_format();
              for (int i = 0; i &lt; gridreport.Rows.Count; i++)
              {
                  string[] temp = new string[13];
                  for (int j = 0; j &lt; gridreport.Columns.Count; j++)
                  {
                      if (j != 12 &amp;&amp; j != 13)
                      {
                          int index = j;
                          if (j &gt; 13) index = j - 2;
  
                          if (j &lt;= 11)
                          {
                              Label lbl = (Label)gridreport.Rows[i].Cells[j].FindControl("lbl" + j);
                              temp[index] = lbl.Text.Replace("-&gt;", "").Replace("&lt;br/&gt;", "");
                          }
                          else
                          {
                              TextBox txt = (TextBox)gridreport.Rows[i].Cells[j].FindControl("txtfinal");
                              temp[index] = txt.Text.Replace("-&gt;", "").Replace("&lt;br/&gt;", "");
                          }
                      }
                  }
                  dt_final.Rows.Add(temp[0], temp[1], temp[2], temp[3], temp[4], temp[5], temp[6], temp[7], temp[8], temp[9], temp[10], temp[11], temp[12]);
              }
  
              DataTable tbl = dt_final.Copy();
  
              DataView dv = tbl.DefaultView;
              dv.Sort = "SrNo ASC";
              tbl = dv.ToTable();
  
              using (ExcelPackage pck = new ExcelPackage())
              {
                  //Create the worksheet
                  ExcelWorksheet ws = pck.Workbook.Worksheets.Add("Updation");
  
                  //Load the datatable into the sheet, starting from cell A1. Print the column names on row 1
                  ws.Cells["A1"].LoadFromDataTable(tbl, true);
  
                  //Format the header for column 1-3
                  using (ExcelRange rng = ws.Cells["A1:K1"])
                  {
                      rng.Style.Font.Bold = true;
                      rng.Style.Fill.PatternType = ExcelFillStyle.Solid;                      //Set Pattern for the background to Solid
                      rng.Style.Fill.BackgroundColor.SetColor(System.Drawing.Color.FromArgb(79, 129, 189));  //Set color to dark blue
                      rng.Style.Font.Color.SetColor(System.Drawing.Color.White);
                  }
  
                  //Example how to Format Column 1 as numeric 
                  using (ExcelRange col = ws.Cells[2, 2, 2 + tbl.Rows.Count, 2])
                  {
                      col.Style.Numberformat.Format = "#,##0.00";
                      col.Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
                  }
  File.WriteAllText(Server.MapPath("files/12345"+txtfilename.Text+".xlsx"), pck.ToString()); // for save file on server but this is not working
  
  
                  Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                  Response.AddHeader("content-disposition", "attachment;  filename=Qa_Report.xlsx");
                  Response.BinaryWrite(pck.GetAsByteArray());
              }
  </code></pre>
  
  <p>this code download the file but i want to save this also on server folder. i found some code from a post but this is not working</p>