开发者

Howto read Range.Top in Excel interop

开发者 https://www.devze.com 2023-03-25 04:02 出处:网络
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.

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

精彩评论

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

关注公众号