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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:48:22+00:00 2026-06-01T05:48:22+00:00

I have a C# WPF application which uses Excel interop libraries to generate and

  • 0

I have a C# WPF application which uses Excel interop libraries to generate and open excel sheets. This works fine till now on an XP machine with Office 2003. But I have recently migrated this to windows 2007 machine which has Excel 2007 running on it. Now my excel exports does’t work anymore. It throws an error like the below:

System.Runtime.InteropServices.COMException (0x800A03EC): The document is corrupt and cannot be opened. To try and repair it, use the Open and Repair command in the Open dialog box and select Extract Data when prompted.
   at Microsoft.Office.Interop.Excel.Workbooks.Open(String Filename, Object UpdateLinks, Object ReadOnly, Object Format, Object Password, Object WriteResPassword, Object IgnoreReadOnlyRecommended, Object Origin, Object Delimiter, Object Editable, Object Notify, Object Converter, Object AddToMru, Object Local, Object CorruptLoad)

I use the code below to open my excel file..

 private void OpenSavedData(string fileName)
        {

            var excelApp = new Application();
            excelApp.Workbooks.Open(
                fileName,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
            excelApp.Visible = true;

            Marshal.ReleaseComObject(excelApp);
        }

This has no trouble working in Office 2003 and XP, but for some reason fails on Win7 & Office 2007. Please can you let me know of any possible workarounds/solutions for this?

Thanks,
-Mike

  • 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-06-01T05:48:23+00:00Added an answer on June 1, 2026 at 5:48 am

    I saw the same problem myself, when I upgrade to Windows 7. Perhaps it’s the sudden shock to my WPF code of running in a 64-bit environment… I’m not sure !

    My solution was a little drastic. I rewrote my WPF app’s “Export to Excel” code completely, to use the OpenXML libraries, rather than using the VSTO libraries (which have always added a level of instability to my .Net apps).

    I’ve documented what I’ve done, and all source code, plus a demo, is provided here:
    http://www.mikesknowledgebase.com/pages/CSharp/ExportToExcel.htm

    Once you’ve linked in my library, exporting a DataSet or DataTable is as simple as adding one line of code.

    CreateExcelFile.CreateExcelDocument(myDataSet, "C:\\MikesExcelFile.xlsx");
    

    It doesn’t get much simpler than that !

    Hope this helps.

    Mike

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

Sidebar

Related Questions

I have a WPF application which uses a JumpList (Recent only). Everything works perfectly
I have a C# WPF (.NET 4.0) application that uses Excel interop to read
we have this application which uses cross app domain (2 app domains in the
Background/context for this question: I have a WPF desktop application. It uses LINQ to
I have a client application (WPF, C#, .net4) which uses POCO entity model connected
I have a WPF application which uses a WPF user control. The user control
I have a C# WPF desktop application which uses SQL Compact 3.5 as its
I have a WPF application which uses some library code for authentication which needs
I have a WPF application which uses a (currently) local database to act as
I have am using a WPF application which uses BitmapSource but I need to

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.