开发者

Howto read Range.Top in Excel interop

Range in the Excel Interop library has Left and Top properties. These are of type Object as stated on MSDN. Trying to cast the result to float gives an error.

Code:

var lastcell = sheet.Cells[row, 1] as Excel.Range;
var topOffset = (float)(lastcell.Top);

Error:

Specified cast is not valid.

How can I retriev开发者_如何学编程e the value as a float (or double..)?


I beileve the results is a double rather than a float so:

var topOffset = (double)(lastcell.Top);

should work.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜