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 465049
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T23:20:13+00:00 2026-05-12T23:20:13+00:00

Whenever I open an xls file I generated on my ASP.NET page with Excel

  • 0

Whenever I open an xls file I generated on my ASP.NET page with Excel 2007, I get the following error:

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 click ‘Yes’, everything looks fine, but it’s annoying to our customers to have to click through it each time. If they use 2003, no problem, but on 2007 it gives this error. Here’s the code I use:

string style = @"<style> .text { mso-number-format: \@ } </style> ";

Response.Clear();
Response.AddHeader("content-disposition", string.Format("attachment;filename=OperationsReport_Rejects_{0}.xls", DateTime.Today.ToString("yyyyMMdd")));
Response.Charset = "";
Response.ContentType = "application/vnd.xls";

StringWriter stringWrite = new StringWriter();
HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

reportOperationsRejectsGridView.RenderControl(htmlWrite);
Response.Write(style);
Response.Write(stringWrite.ToString());
Response.End();

Does anyone know what is causing it to behave differently on 2003 and 2007?

  • 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-12T23:20:14+00:00Added an answer on May 12, 2026 at 11:20 pm

    Office 2007 uses XML based file formats that are different from the previous binary file formats.

    What Excel 2007 saves is not an .xls file, but an .xlsx file.

    What you are creating is actually neither. It’s an HTML export of an excel file. Some versions will seamlessly import the HTML as an excel document, some versions will warn you that it’s actually not an Excel document, before importing it.

    If you create an actual .xls file, Excel 2007 will open it in compatibility mode without complaining.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Whenever I open some help within eclipse I get a page saying: Server Error.
Background: For some reason, whenever a user tries to open an xslx (excel 2007)
I'm getting an error whenever I load Management Studio or open a folder in
I've developed a webpage in visual studio, but whenever I open the page in
I have a SharePoint 2007 portal, that contains several document libraries. Whenever I open
Whenever I open a new terminal window I now get: -bash: /usr/local/bin/heroku: /usr/local/bin/ruby: bad
I want that whenever i open a new c++ file in vim in linux
Whenever I open a Bash shell, my classpath is someProgram. I know that adding
I'm not sure if it's just me, but whenever I open .txt files in
Whenever I collapse or open node in the tree view, it jumps up and

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.