Skip to content
Loading
  • Madhanmohan Devarajan
    0
    Sreedhar,
    Please help me to understand better and to provide appropriate solution for your problem. Where does the excel file stored? and does the MVC view has the link to excel file?
    When the user clicks on the link it should download to the user's downloads on his desktop. Am i right? Please correct me if i am wrong.
    0
  • 0
    Hi Madhan ,
    i was generating excel sheet using data table data and downloading,the excel sheet is downloaded, but the problem is when i open the downloaded excel sheet i am getting a warning message like

    The file you are trying to open is Different format than specified by the file extension

    with a yes or no buttons
    how to prevent the above warning.
    iam downloading excel using response.write() method, is there any other way to prevent the above message for downloading excel sheet
    Thanks ,
    L Sreedhar
    0
  • Madhanmohan Devarajan
    0
    Please let me this error / warning appears only in your desktop?
    Also check the below link that deals with the similar issue of yours. Hope it will resolve your issue.
    https://support.microsoft.com/en-us/kb/948615
    0
  • Bikesh Srivastava
    0
    Hi,
    you can visit on micrsoft site.
    https://msdn.microsoft.com/en-us/library/dd264733.aspx
    0
  • 0
     Hi Ramesh ,
     
    below code working fine but i am getting the warning message
    but the problem is when i open the downloaded excel sheet i am getting a warning message like

    The file you are trying to open is Different format than specified by the file extension

    with a yes or no buttons
    how to prevent the above warning.
    Thanks ,
    L Sreedhar
    0
  • Ramesh Palaniappan
    0
    @Sreedhar: Instead of using excel content type, try below approach. It will download as .csv file and wont give error you mentioned.
    1. Response.Clear();
    2. Response.AddHeader("content-disposition","attachment;filename="+strFileName_Date+".csv");
    3. Response.Charset="";
    4. Response.ContentType="application/vnd.ms-excel";
    5. HttpContext.Current.Response.Write(data);
    6. HttpContext.Current.Response.Flush();
    7. HttpContext.Current.Response.End();
    0
  • 0
    Hi Ramesh,
    ya it worked , but in my case i need to download a excel sheet for generating a report.
    Thanks ,
    L Sreedhar
    0
  • Ramesh Palaniappan
    0
    @Sreedhar: csv file also kind of excel file only. If you download its as excel we cont resolve your error. I also tried many approach. But nothing works out. Better download as below approach only.
    Note: If i'm answered your question, please mark this approach as answered. Thanks
    0