Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7689179
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T20:06:15+00:00 2026-05-31T20:06:15+00:00

In my asp.net, C# application we are generating and downloading .xls file. But when

  • 0

In my asp.net, C# application we are generating and downloading .xls file. But when I’m trying to open, it’s giving a message

“The file you are trying to open, ‘filename.xls’, is in a different
format than specified by the file extension. Verify that the file is
not corrupted and is from a trusted source before opening the file. Do
you want to open the file now?”

If I press ‘Yes’ it’s opening. I changed the file extension to .xlsx, still same message. Can anyone tell me why this is happening? I’ve added .xlsx MIME type extension in IIS manager with MIME Type as application/vnd.openxmlformats-officedocument.spreadsheetml.sheet. Still it’s showing the same message. Please suggest how can I get rid off it.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T20:06:16+00:00Added an answer on May 31, 2026 at 8:06 pm

    Do you completely create the xls file or do you copy and fill a template xls file ?
    An incorrect format template file may cause the problem.

    Also, what provider do you use to fill your file ?
    – Microsoft.ACE.OLEDB.12.0 for xlsx/xlsm ?
    – Microsoft.Jet.OLEDB.4.0 for xls ?

    An incorrect provider/extension combination may cause the problem.

    According to your comment, here is a part of code where I have done that in the past :
    ( commented some of the lines as I don’t remember why they where useful )

    Response.Clear();                           
    Response.ContentType = "application/vnd.ms-excel";
    //Response.ContentEncoding = Encoding.Default; 
    //Response.Charset=""; 
    Response.AddHeader("Content-Disposition: ",
        String.Format(@"attachment; filename={0}",myfileName));
    
    //EnableViewState = false; 
    
    Response.Write(myFileContentAsString); 
    Response.Flush();
    Response.Close();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm generating a reporting services report from an ASP.NET (MVC) based application but am
In my ASP.Net application I'm generating a Excel file using MsExcel Object Libby (Com-InterOp)
my ASP.NET application reads an xml file to determine which environment it's currently in
What is the correct way of generating random numbers in an ASP.NET MVC application
We have an ASP.NET application that queues some of its long-running operations (generating reports,
I know of the ASP.NET MVC ActionLink helper for generating links to the application's
For configuring my ASP.Net Application I'm using Custom Configuration Sections in my web.config. But
I am creating an asp.net mvc 2 application generating my view model dynamically depending
I'm generating a list of radio buttons within my asp.net mvc Application and want
In my ASP.NET MVC 4 application's RouteConfig file, I have registered the following default

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.