[英]Faster way to access Range using Excel.Interop
There are two ways I know- 我知道两种方法-
_xlWorksheet.Range[_xlWorksheet.Cells[1, 1], _xlWorksheet.Cells[10, 10]].Value2 = myarray.ToArray();
OR 要么
_xlWorksheet.Range["A1", "J10"].Value2 = myarray.ToArray();
OR 要么
Is there any other faster way? 还有其他更快的方法吗?
As per my understanding, when I use 据我了解,当我使用
_xlWorksheet.Range[_xlWorksheet.Cells[1, 1], _xlWorksheet.Cells[10, 10]]
there will be three calls to interop. 将有三个呼叫互操作。 But, in case of
但是,如果
_xlWorksheet.Range["A1", "J10"]
there will be only one call. 只会打一个电话。
I am not sure which one works faster. 我不确定哪个会更快。
As far as I understand your question there is no "FAST" way when choosing .Range[_xlWorksheet.Cells[1, 1], _xlWorksheet.Cells[10, 10]]
or Range["A1", "J10"]
They are the same. 据我了解您的问题,选择
.Range[_xlWorksheet.Cells[1, 1], _xlWorksheet.Cells[10, 10]]
或Range["A1", "J10"]
时没有“快速”方法相同。
In Excel, you can refer to a range, say A1:A10
, in some of these ways 在Excel中,您可以通过以下某些方式引用范围,例如
A1:A10
。
Debug.Print Sheets("Sheet1").Range("A1:A10").Address
Debug.Print Sheets("Sheet1").Range(Sheets("Sheet1").Range("A1"), Sheets("Sheet1").Range("A10")).Address
Debug.Print Sheets("Sheet1").Range(Sheets("Sheet1").Cells(1, 1), Sheets("Sheet1").Cells(10, 1)).Address
Choosing one of the above will NOT determine the performance. 选择以上其中一项将不会决定性能。 What WILL determine the performance is HOW you read/write to them
什么将决定其表现是如何你读/写他们
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.