0

I have excel 2016. When I try to save excel file through code it showing a warning message as

"The file format and extension of 'ReviewCounts.xls' don't match. The file could be corrupted or unsafe. Unless you trust its source, don't open it. Do you want to open it anyway?"

After clicking Yes it has been opened. How to avoid that popup ?

My code:

Dim attachment As String = "attachment; filename=ReviewCounts.xls"
    Response.ClearContent()
    Response.AddHeader("content-disposition", attachment)
    Response.ContentType = "application/ms-excel"
    Dim strexcelExport As String = String.Empty
    ExportReviewDetails(strexcelExport, "Excel") 'Method to prepare excel
    Response.Write(strexcelExport)
    Response.End()

I tried with .xlsx format also but in this case file not even saved.

  • Possible duplicate of [What is a correct mime type for docx, pptx etc?](http://stackoverflow.com/questions/4212861/what-is-a-correct-mime-type-for-docx-pptx-etc) – Prisoner Nov 07 '16 at 09:45
  • It is very unlikely that your code produces Excel file as you have it as string... – Alexei Levenkov Nov 07 '16 at 09:51
  • @AlexeiLevenkov: I'm making excel in **ExportReviewDetails** method –  Nov 07 '16 at 10:29

0 Answers0