title: How to save created excel file to Client pc in ASP.NET
body: <p>I am creating a excel report and html report in asp.net when I clik the button and my application create it and save to the client desktop but, it is not working correctly because excel file is creating in server's desktop. How can I fix this matter ?</p>
  
  <p>Thank you for your reply. </p>
  
  <pre><code>string CurrentDate;
  DateTime saveNow = DateTime.Now;
  CurrentDate = saveNow.Date.ToShortDateString();
  string reportContent = prepareHTM();
  
  string pathFile = Environment.GetFolderPath(Environment.SpecialFolder.CommonDesktopDirectory) + "\\As_Build_Report_ "+ CurrentDate + ".html";
  
  using (StreamWriter outfile = new StreamWriter(pathFile, true))
  {
      outfile.WriteLine(reportContent);
  }
  System.Diagnostics.Process.Start(pathFile);
  </code></pre>
  
  <hr>
  
  <pre><code>object missing = System.Reflection.Missing.Value;
  //Start Excel Application.
  Excel.Application oXL = new Excel.Application();
  oXL.Visible = true; //display Application .            
  Excel._Workbook oWB = (Excel._Workbook)(oXL.Workbooks.Add(missing));//create a new workbook.
  Excel._Worksheet oSheet = (Excel._Worksheet)oWB.ActiveSheet; //create a sheet                
  
  string CurrentDate;
  DateTime saveNow = DateTime.Now;
  CurrentDate = saveNow.Date.ToString();
  int keep = 5;
  string project = list[0].Project;
  oSheet.Cells[1, 3] = "MiKES Configuration Management __" + project + "__ As-Built Report";
  oSheet.Cells[3, 1] = "Report Date :";
  oSheet.Cells[3, 2] = CurrentDate;
  
  oSheet.Cells[keep, 1] = "PART NO";
  oSheet.Cells[keep, 2] = "REF.DES.";
  oSheet.Cells[keep, 3] = "DESCRIPTION";
  oSheet.Cells[keep, 4] = "SERIAL NO";
  oSheet.Cells[keep, 5] = "C/S";
  oSheet.Cells[keep, 6] = "D/C";
  oSheet.Cells[keep, 7] = "REMARK";
  keep++;
  foreach(Classes.CMNewPart item in list)
  {
      try
      {
          oSheet.Cells[keep, 1] = item.PartNo;
          oSheet.Cells[keep, 2] = item.RefDes;
          oSheet.Cells[keep, 3] = item.Description1;
          oSheet.Cells[keep, 4] = item.SerialNo;
          oSheet.Cells[keep, 5] = item.Cs;
          oSheet.Cells[keep, 6] = item.Dc;
          oSheet.Cells[keep, 7] = item.Remark;
      }
      catch (Exception)
      {
  
      }
      keep++;
  }
  </code></pre>