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.
精彩评论