title: Use epplus to create .xlsm file
body: <p>I'm trying to have a website export a .xlsm file and I can't seem to find anything that helps. Here's a simple example I'm using to test building a .xlsx file (which works). </p>
  
  <pre><code>@using OfficeOpenXml;
  &lt;html&gt;
      &lt;body&gt;
          &lt;div id="page-wrapper"&gt;
          @{
              // Change file extension to xlsm to test
              string fileExtension = "xlsm";
              ExcelPackage p = new ExcelPackage();
              p.Workbook.Worksheets.Add("Worksheet Name");
              int LatestWorksheetNumber = p.Workbook.Worksheets.Count;
              ExcelWorksheet ws = p.Workbook.Worksheets[LatestWorksheetNumber];
  
              ws.Cells[1, 1].Value = "Test";
  
              //Generate A File
              Byte[] bin = p.GetAsByteArray();
              string filename = "filename";
              try
              {
                  //Download the file as an attachment
                  Response.Clear();
                  Response.ClearContent();
                  Response.ClearHeaders();
                  Response.Cookies.Clear();
  
                  string ContentType = "";
                  if (fileExtension == "xlsx")
                  {
                      ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                  }
                  else
                  {
                      ContentType = "application/vnd.ms-excel.sheet.macroEnabled.12";
                  }
                  Response.GetType();
                  Response.ContentType = ContentType;
                  Response.AddHeader("content-disposition", "attachment;  filename=" + filename + "." + fileExtension);
                  Response.BinaryWrite(bin);
                  Response.End();
                  &lt;p&gt;File Created&lt;/p&gt;
              }
              catch (Exception e)
              {
                  &lt;p&gt;@e.Message&lt;/p&gt;
              }
  
          }
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>After changing the file extension to .xlsm the file is generated but when I try to open the file in Excel I get an error saying that the extension isn't correct. I thought the only thing I would have to change would be the content type header but that's obviously not the issue. What else am I missing??? Any guidance would be appreciated!</p>