读取 Excel 互操作单元格时出错:无法转换方法组“ToString”到非委托类型“String”
谁能告诉我这段代码做错了什么?我正在尝试读取单元格并将值分配给字符串node1。
public void createEdgeListFromRange(Microsoft.Office.Interop.Excel.Workbook workbook)
{
Excel.Worksheet ws = (Excel.Worksheet)workbook.Worksheets.get_Item("Time Series");
Excel.Range range = ws.UsedRange;
for (int row = 0; row < range.Rows.Count; row++ )
{
String node1 = ws.Cells["A", row].ToString;
}
}
Can anyone tell me what I a doing wrong with this code? I am trying to read in a cell and assign the value to the String node1.
public void createEdgeListFromRange(Microsoft.Office.Interop.Excel.Workbook workbook)
{
Excel.Worksheet ws = (Excel.Worksheet)workbook.Worksheets.get_Item("Time Series");
Excel.Range range = ws.UsedRange;
for (int row = 0; row < range.Rows.Count; row++ )
{
String node1 = ws.Cells["A", row].ToString;
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您有一个拼写错误:
因为
ToString()
是方法调用,所以ToString
(如果存在)是属性(或字段)调用。You have a typo:
because
ToString()
is a method call,ToString
(if it exists) is a property (or field) call.