Why do .NET 6 Office Interop Dynamic References No Longer Work

Viewed 56

I'm upgrading a WPF C# project from .NET 4.8 to .NET 6 - Happily, .NET 6 has support for Word and Excel Office Interop. However, I've found that where before I was able to reference things like Excel Ranges and Range properties such as Font, Interior, etc. without casting to Range, now I do. So,

var cell = xlWs.Cells[r, c];
cell.Interior.Color = rowColor;

now has to be coded:

Range cell = ((Range)xlWs.Cells[r, c]);
cell.Interior.Color = rowColor;

Not the end of the world, but is forcing me to make a few hundred changes I'd rather not have to make. Is there any way around this? Has anybody else migrated older Interop code to .NET 6 yet?

Thanks.

0 Answers
Related