title: C# Epplus Save Byte file as XLS in a Desktop Application
body: <p>I need to save an ExcelPackage as XLS file. I try to do this and i know how to change content type in a web application but i can't find any solution in a Desktop environment.</p>
  
  <p>Now i am using this code:</p>
  
  <pre><code>    using (ExcelPackage p = new ExcelPackage())
      {
         string filename = "OCL_" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".xls";
         string PathToCSV = "App_Data/OCL/";
         string OCLfolder = AppDomain.CurrentDomain.BaseDirectory + PathToCSV;
         string savepath = OCLfolder + "/" + filename;
         System.IO.FileInfo strfilePath = new System.IO.FileInfo(savepath);
         //create a new workbook
         p.Workbook.Properties.Created = DateTime.Now;
         p.Workbook.Properties.Title = filename;
         //create a new worksheet
         p.Workbook.Worksheets.Add(filename);
         ExcelWorksheet ws = p.Workbook.Worksheets[1];
         createExcelData(ws, idCliente, idDestinatario, idSpedDati);
         ws.Cells[ws.Dimension.Address].AutoFitColumns();
         for (int col = 1; col &lt;= ws.Dimension.End.Column; col++)
         {
            ws.Column(col).Width = ws.Column(col).Width + 1;
         }
         byte[] bin = p.GetAsByteArray();
         strfilePath.Directory.Create();
         File.WriteAllBytes(savepath, bin);
         return savepath;
     }
  </code></pre>
  
  <p>If i save the file as .xlsx i have no problem but if i save as .xls i have an error before opening the file: </p>
  
  <blockquote>
    <p>"The file format differs from the format that the file name extension
    specifies"</p>
  </blockquote>