开发者

Range subtraction in the Excel Object Model

开发者 https://www.devze.com 2022-12-30 19:00 出处:网络
When using Excel Interop libraries from .NET, I can find a Range object representing the cell offset from Range X by calling something like.

When using Excel Interop libraries from .NET, I can find a Range object representing the cell offset from Range X by calling something like.

Range Y = X.Range[2,3];

But what should I do to perform the inverse operation, ie: I have two Range objects, A and B, and I would like to find out by how ma开发者_C百科ny rows/columns B is offset from A.

Does anyone know the easiest way to do this? Is there a library function?

Thanks.


You want Longs returned?

RowOffset = B.Cells(1,1).Row - A.Cells(1,1).Row
ColOffset = B.Cells(1,1).Column - B.Cells(1,1).Column

That will tell you how much the top left cells are offset.

0

精彩评论

暂无评论...
验证码 换一张
取 消