从“Object(,)”类型到“String”类型的转换无效 [英] Conversion from type 'Object(,)' to type 'String' is not valid

查看:271
本文介绍了从“Object(,)”类型到“String”类型的转换无效的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用VB.Net代码处理/阅读Excel工作簿。

如果工作表少于20000行,一切正常,但如果超过20000则会抛出异常。



I am handling/reading Excel workbook using VB.Net Code.
Everything goes OK if worksheet has less than 20000 rows, but if it is more than 20000 then it throws following exception.

InvalidCastException Occured
Conversion from type 'Object(,)' to type 'String' is not valid.





我的问题是它为什么有效,而其他时间没有?

可能是什么潜在问题?



代码如下:





My problem is that why it works some time and does not other time?
What could be the potential problem??

Code looks like this:

uArea.Digits = CurrentRow.Columns(AREA_DIGIT).value 
uArea.ValidFrom = CurrentRow.Columns(VALID_FROM).value





编辑:这可能吗是我需要暴露或处置excel对象的原因?在这种情况下,是否可以处置Excel对象?或者我可以使用GC.Collect吗?请帮忙。



Could this be the reason that i need to expose or dispose excel object ? in that case , is it possible to dispose Excel object? OR can i use GC.Collect? Please Help.

推荐答案

这个错误实际上可能与excel的大小无关。在行20000之后的行之一可以具有可以是不同类型的一些数据。值得对Excel文件进​​行快速数据验证。
This error may actually have nothing to do with the size of the excel. One of the rows after row 20000 may have some data that may be of a different type. It will be worth doing a quick data validation of the Excel file.


这篇关于从“Object(,)”类型到“String”类型的转换无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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