Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/326.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# 如何使用Range.Range属性_C#_Excel_Vsto - Fatal编程技术网

C# 如何使用Range.Range属性

C# 如何使用Range.Range属性,c#,excel,vsto,C#,Excel,Vsto,有人能告诉我为什么下面在Office 2010 Excel VSTO中使用Range.Range属性不起作用吗?我在Stackoverflow和其他网站上对此进行了大量研究,但没有找到答案 currCol.Range[currCol.Cells[1, 1], currCol.Cells[500, 1]].Value2 其中currCol是一个范围对象,表示Excel工作表中的列范围。我只想得到列中的前500行 上面的表达式返回空值。我也尝试过用Value替换Value2,但仍然没有成功。结果是

有人能告诉我为什么下面在Office 2010 Excel VSTO中使用Range.Range属性不起作用吗?我在Stackoverflow和其他网站上对此进行了大量研究,但没有找到答案

currCol.Range[currCol.Cells[1, 1], currCol.Cells[500, 1]].Value2
其中currCol是一个范围对象,表示Excel工作表中的列范围。我只想得到列中的前500行


上面的表达式返回空值。我也尝试过用Value替换Value2,但仍然没有成功。

结果是,你没有说出你想要什么,或者什么不起作用。如果要返回具有500个值的二维数组,请尝试:ws.Range[currCol.Cells[1],currCol.Cells[500],其中ws是引用具有currCol范围的工作表的变量。你也可以使用:currCol.Cells[1]。Resize[500,1]ws.Range[currCol.Cells[1],currCol.Cells[500]]来完成这个任务!非常感谢,道格!