Problems with Microsoft Excel COM Automation

So, I wrote a method in my product product a year and a half ago that uses Excel 2007 COM automation to export data, but now I find that it no longer works on machines in the office.

I tested the functionality of the method on my machine and got the same result.

Digging deeper, I found that when I get to

var excel = Excel.Application

If I add a clock to an excel object, I see that each property throws a cast exception.

After some research, I saw something about registry keys that could interfere with automation. I managed to break through and delete the registry key:

HKEY_CLASSES_ROOT\TypeLib{00020813-0000-0000-C000-000000000046}\1.7

With the following string value defined internally:

"PrimaryInteropAssemblyName"="Microsoft.Office.Interop.Excel, Version=14.0.0.0

Then I ran the same piece of code again, only this time it did a great job.

, , , .

- ?

+3
1

14 Office - Office 2010, , 2007 2010 .

, , , Microsoft.Office.Interop.Excel, Version=14.0.0.0 , .

, , , Microsoft.Office.Interop.Excel, Version=12.0.0.0, Microsoft.Office.Interop.Excel, Version=14.0.0.0.

, .

, , , , , .

+1

Source: https://habr.com/ru/post/1764998/


All Articles