Excel COM Interop - getRange异常来自HRESULT:0x800A03EC [英] Excel COM Interop - get_Range Exception from HRESULT: 0x800A03EC

查看:1115
本文介绍了Excel COM Interop - getRange异常来自HRESULT:0x800A03EC的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到此异常:

  System.Runtime.InteropServices.COMException:HRESULT异常:0x800A03EC。 

此位代码:

  foreach(xlWorkSheet1.UsedRange.Cells中的Excel.Range rng)
{

if(rng.Value2!= xlWorkSheet2.get_Range(rng,Type。 Missing).Value2)// here
{
...........

Im基本上试图在c#中逐个单元格地比较两个excel文件,但get_range似乎给我这个错误。



p>

感谢

解决方案

我认为你应该在



或者,您可以遍历已使用的范围的行和列,并提供xlWorkSheet2.Cells [row ,column]。


I am recieving this exception:

System.Runtime.InteropServices.COMException: Exception from HRESULT: 0x800A03EC.

on this bit of code:

         foreach(Excel.Range rng in xlWorkSheet1.UsedRange.Cells)
            {       

                if (rng.Value2 != xlWorkSheet2.get_Range(rng,Type.Missing).Value2) //here
                {
...........

Im basically trying to compare two excel files cell by cell in c# but get_range seems to be giving me this error.

Any ideas?

Thanks

解决方案

I think you should be somewhat more specific in getting the range from xlWorkSheet2 by using the address property of rng.

Alternatively you can iterate through the rows and columns of the usedrange and provide the row and column in xlWorkSheet2.Cells[row, column].

这篇关于Excel COM Interop - getRange异常来自HRESULT:0x800A03EC的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆