我尝试了以下内容:(VB.Net代码)
Dim data As Object
Dim range As Excel.Range
range = WB.Sheets("mysheet").Range("A1:C5")
data = range.Value ' Here WB is the Wrokbook object
' Until here its working fine.
' During Debug: I can see data with values for [ (0,0), (0,1), (0,2), (1,0), .. ]
' Now following line gives an exception !!
Dim val = data(0,0) ' Index out of range exception.
如何像数组一样迭代所谓的RangeValueDataType
对象?
参考:http://msdn.microsoft.com/en-us/library/bb238606(v=office.12).aspx
答案 0 :(得分:1)
AFIAK Excel范围数据是具有1个基本索引的数组,即第一个项目将是data(1, 1)
。