Excel interop works on machine with Office 2007 but fails on machine with Office 2010

前端 未结 1 421
無奈伤痛
無奈伤痛 2020-12-31 12:16

I have a C# WPF (.NET 4.0) application that uses Excel interop to read data from an Excel file.

When I run this app on my development machine, which has Excel 2007,

相关标签:
1条回答
  • 2020-12-31 12:47

    Preliminary answer: my software was fine and something was wrong with the setup on that particular machine.

    Edit

    I just found out something that is probably the source of the problem. The problem machine has Office, but it is set up as click-to-run (runs off the internet) rather than MSI-based (runs from an EXE). This means that certain registry settings, DLLs, components, etc. are not available to Microsoft.Office.Interop.Excel, so it fails.

    Edit 2

    That was definitely the problem. Just upgraded to a full MSI-based installation of Office, and everything works great.

    Edit 3

    Added this as a bug to Microsoft Connect:

    https://connect.microsoft.com/VisualStudio/feedback/details/672276/excel-interop-fails-on-machine-where-office-is-installed-as-click-to-run#details

    0 讨论(0)
提交回复
热议问题