Page view counter

Problems in Exporting to Excel 2007

Last post 10-13-2008 4:34 AM by EJLindsay. 21 replies.

Sort Posts:

  • Problems in Exporting to Excel 2007

    02-01-2007, 9:23 PM
    • Loading...
    • EJLindsay
    • Joined on 10-03-2003, 10:49 AM
    • Posts 139
    • Points 297

    When I export a GridView to Excel 2007 I get an error message:

     The file you are trying to open < > 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?

     This worked OK with Excel 2003.  I called Microsoft and they told me I was using a non-release version which is not true.  My Office 2007 was downloaded from MSDN in Dec 2006.  I found a reference on the Internet that said this problem would be fixed in the released version but it is not.

    Help

     Jay

  • Re: Problems in Exporting to Excel 2007

    02-02-2007, 12:49 AM
    • Loading...
    • NileshDesh
    • Joined on 01-05-2007, 3:59 AM
    • Sydney, AUS/New York, USA
    • Posts 186
    • Points 752

    Jay,

    Many times I've found that disabling ViewState altogether solves the problem. Let me if that works for you.

    Nilesh Deshpande
    MCP, MCAD.Net, MCSD.Net, SCJP

    Future is here, it's just not widely distributed yet.
  • Re: Problems in Exporting to Excel 2007

    02-05-2007, 4:28 AM
    Answer

    Hi, Jay

    This is a known issue that will be addressed before Excel 2007 ships. The alert can be safely ignored when using Excel 2002 or 2003 to save a file to the new Excel 2007 formats (XLSX, XLSB, etc.)

    other reference : http://support.microsoft.com/kb/317719

    Hope this helps

    Please give us feedback no matter whether you get your answer.
    Please "mark as answer" if it's useful for you

    Sincerely,
    Jerome
  • Re: Problems in Exporting to Excel 2007

    04-03-2007, 7:13 PM
    • Loading...
    • EJLindsay
    • Joined on 10-03-2003, 10:49 AM
    • Posts 139
    • Points 297

    The question of exporting to Excel 2007 was never answered.  I am using the most up-to-date Excel 2007 and VS 2005 and I still get the error  message below.

     The file you are trying to open < > 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?

     Any update.  I cannot believe this has not been fixed yet.

     Jay

  • Re: Problems in Exporting to Excel 2007

    04-20-2007, 11:00 AM
    • Loading...
    • whereizben
    • Joined on 04-20-2007, 2:58 PM
    • Posts 1
    • Points 2

    I am having the same issue when I run scripts on our web site that allow us to export tabled data to excel.  Excel 2003 does not complain at all, but 2007 insists that it is the wrong format, using the exact same error message. 

    My version is 12.0.4518.1014 

  • Re: Problems in Exporting to Excel 2007

    04-20-2007, 12:12 PM
    • Loading...
    • EJLindsay
    • Joined on 10-03-2003, 10:49 AM
    • Posts 139
    • Points 297

    I contacted MicroSoft and their answer was that this is a new security warning and there is no way to get around it.  If you use XML as the file format then you do not get that message.

     Jay

  • Re: Problems in Exporting to Excel 2007

    09-18-2007, 4:46 PM
    • Loading...
    • phildoble
    • Joined on 09-18-2007, 8:37 PM
    • Posts 1
    • Points 2

    Using XML as the file format, you do still get the problem - this is delivering the document using the  "application/vnd.ms-excel" MIME-type. If I use "text/xml" instead, the browser does not open the document in Excel. We still need a proper solution to this.

  • Re: Problems in Exporting to Excel 2007

    11-19-2007, 9:20 AM

    I am also having the same problem, it seems that we are not alone with this issue either.  I have browsed the web for a few days but to no avail.  I set up an xml filestream from an aspx page, it works fine in Excel 2003 but not in 2007.  I do not believe that this problem will ever be resolved for Excel 2007. Regards TSB.

  • Re: Problems in Exporting to Excel 2007

    01-31-2008, 2:47 PM
    • Loading...
    • dclash
    • Joined on 09-07-2006, 7:29 PM
    • Posts 6
    • Points 27

    Has anyone resolved this issue?  I am having the same problem.

  • Re: Problems in Exporting to Excel 2007

    02-06-2008, 9:32 PM
    • Loading...
    • ageuni
    • Joined on 01-02-2008, 2:16 AM
    • Posts 3
    • Points 2

    I am also having the same problem...any solutions floating around out there?

  • Re: Problems in Exporting to Excel 2007

    02-27-2008, 12:04 AM
    • Loading...
    • swathi556
    • Joined on 03-28-2006, 5:15 AM
    • Posts 6
    • Points 27

    I have same problem...any solution?

  • Re: Problems in Exporting to Excel 2007

    03-27-2008, 4:24 PM
    • Loading...
    • Nachos
    • Joined on 03-27-2008, 8:22 PM
    • Posts 5
    • Points 6

    Same problem.

  • Re: Problems in Exporting to Excel 2007

    03-31-2008, 6:22 AM
    • Loading...
    • jobejufranz
    • Joined on 07-09-2007, 9:56 AM
    • Virtual Reality
    • Posts 237
    • Points 972

    Hi Guys,

    Please refer to http://forums.asp.net/p/1101709/2265897.aspx#2265897 as it may help you.

    Please don't forget to click "Answer" if it helps you as it may help others also.
  • Re: Problems in Exporting to Excel 2007

    04-11-2008, 8:25 AM
    • Loading...
    • karyani
    • Joined on 04-11-2008, 12:20 PM
    • Posts 38
    • Points 12
      

    I solved this problem by storing in the database the file extension (FileExtension ) when it is uploaded.( .xlsx or .xls)

    Then when opening the file from the database I check the extension and use

         Response.ContentType = "application/vnd.ms-excel";    Response.AppendHeader("Content-disposition", "attachment; filename=” + name + FileExtension);

        Response.BinaryWrite(the binary file);

     

  • Re: Problems in Exporting to Excel 2007

    04-16-2008, 5:03 PM
    • Loading...
    • Nachos
    • Joined on 03-27-2008, 8:22 PM
    • Posts 5
    • Points 6

    Kudos Karyani!

    For .xls files, that's eliminating this particular message, on my application that involves a DataGrid and SQL Server.  Incidentally, that application had been failing to download Word 2007 files; this edit fixed it.

    On the other hand, for the application I tried this with earlier, I continue to get the message. 

    Differences between the two apps follow.

    App where the message persists (App A):

    2.0 .Net C# SqlServer2005 (file not stored in SQL though) GridView

    Does not store the file content in a database rather sends it directly to the browser as a Response

     

     

    App where the Excel 2007 message stopped appearing and also the Word 2007 download was enabled by this edit (App B):

    1.1 .Net VB SqlServer 8.0 DataGrid

    App first redirects to a blank aspx where the Response is composed.

     

     

    App A (rendering GridView grvRequestors to a Response)

    string attachment = "attachment; filename=Requestors.xls";

    Response.ClearContent();

    Response.AddHeader(
    "content-disposition", attachment);

    Response.ContentType = "application/vnd.ms-excel";

    StringWriter sw = new StringWriter();HtmlTextWriter htw = new HtmlTextWriter(sw);

    grvRequestors.RenderControl(htw);

    Response.Write(sw.ToString());

    Response.End();

     

     

     

     

     

    App B (download a file whose content is stored as binary in SQL)

    When users clicks to download:

    Response.Redirect("./downloadFile.aspx")

     

    in downloadFile.aspx

    Response.AddHeader("Content-disposition", "attachment;filename=" & dsAttachments.Tables(0).Rows(0)("FileName"))

    Response.ContentType = dsAttachments.Tables(0).Rows(0)("FileType")

    Response.BinaryWrite(dsAttachments.Tables(0).Rows(0)("Attachment")) 'content

    Response.Flush()

     

     

     

     

     

     

     

Page 1 of 2 (22 items) 1 2 Next >