Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/286.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/iphone/43.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Excel COM互操作-从HRESULT获取范围异常:0x800A03EC_C#_Com_Interop - Fatal编程技术网

C# Excel COM互操作-从HRESULT获取范围异常:0x800A03EC

C# Excel COM互操作-从HRESULT获取范围异常:0x800A03EC,c#,com,interop,C#,Com,Interop,我收到此例外情况: System.Runtime.InteropServices.ComeException:来自HRESULT的异常: 0x800A03EC 在这段代码中: foreach(Excel.Range rng in xlWorkSheet1.UsedRange.Cells) { if (rng.Value2 != xlWorkSheet2.get_Range(r

我收到此例外情况:

System.Runtime.InteropServices.ComeException:来自HRESULT的异常: 0x800A03EC

在这段代码中:

         foreach(Excel.Range rng in xlWorkSheet1.UsedRange.Cells)
            {       
                
                if (rng.Value2 != xlWorkSheet2.get_Range(rng,Type.Missing).Value2) //here
                {
...........

我基本上是试图逐个单元格比较两个excel文件,但
get\u range
似乎给了我这个错误。为什么?

我认为通过使用rng的address属性从xlWorkSheet2获取范围应该更具体一些


或者,您可以遍历usedrange的行和列,并在xlWorkSheet2中提供行和列。单元格[行,列]。

FYI 0x800A03EC=ERROR\u INVALID\u flagshanks,我通过执行xlWorkSheet2.get\u Range(rng.get\u地址(Type.Missing,Type.Missing,Excel.XlReferenceStyle.xlA1,Type.Missing,Type.Missing,Type.Missing),类型。缺少)。值2)