在用C#写Excel的Range的值时候出现了问题。
range.set_Value(Missing.Value,datas);
其中range的类型为Microsoft.Office.Interop.Excel.Range.
datas的类型为object[,]的二维数组。
range的范围和datas的数据个数是匹配。
datas的数据量为1K(左右) * 7的样子能正常设置。
当数据量为4K(左右) * 7的样子有时能成功,有时报错。
但是当数据量为10K(左右) * 7的样子偶尔也能成功,但是设置的数据和datas的数据不一致,多数情况是报错。
具体错误的如下:
System.Runtime.InteropServices.COMException was unhandled by user code
Message="The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"
Source="mscorlib"
ErrorCode=-2147417851
StackTrace:
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Microsoft.Office.Interop.Excel.Range.set_Value(Object RangeValueDataType, Object )还有个奇怪的问题是,在其他机子上是没有问题的。
请高手看看是什么原因。
range.set_Value(Missing.Value,datas);
其中range的类型为Microsoft.Office.Interop.Excel.Range.
datas的类型为object[,]的二维数组。
range的范围和datas的数据个数是匹配。
datas的数据量为1K(左右) * 7的样子能正常设置。
当数据量为4K(左右) * 7的样子有时能成功,有时报错。
但是当数据量为10K(左右) * 7的样子偶尔也能成功,但是设置的数据和datas的数据不一致,多数情况是报错。
具体错误的如下:
System.Runtime.InteropServices.COMException was unhandled by user code
Message="The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"
Source="mscorlib"
ErrorCode=-2147417851
StackTrace:
at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Int32[] aWrapperTypes, MessageData& msgData)
at Microsoft.Office.Interop.Excel.Range.set_Value(Object RangeValueDataType, Object )还有个奇怪的问题是,在其他机子上是没有问题的。
请高手看看是什么原因。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货