问题描述
我认为我对Interop.Excel.Range对象的用途有错误的理解。
Worksheet rfi_sheet = wb.Worksheets.get_Item("rfi");
Excel.Range range = rfi_sheet.Range[start_col + "1",calculate_end_column_from_offset(start_col,end_col_offset) + "17"])
例如range
是从“ A1”到“ M17”的Excel.Range
。我的假设是这样的表达式:
range[1,5].Value // or.Text
将产生此范围的第一行和第五列的值。但是事实并非如此。我收到以下错误:
error CS1061: 'object' does not contain a deFinition for 'Value' and no accessible extension method 'Value' accepting a first argument of type 'object' Could be found (are you missing a using directive or an assembly reference?)
起初,我认为Range只是单元格地址的列表,因此如果不参考工作表就无法从中检索值。但是事实证明这是错误的,因为它可以起作用:
Excel.Range sub_range = range[1,5];
sub_range[1,1].Text //returns the cell content.
为什么会这样呢?为什么我不能直接从某个范围而是从存储在额外变量中的同一范围的sub_range中直接访问单元格内容?
谢谢!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)