如何在VB.net中编辑单元格值 – 使用.Interop.Excel
这是一个简单的问题。 我有这个代码:
CurrentRow = 3 MyColumn = 2 CurrentCell = (CurrentRow & "," & MyColumn) WorkingSheet.Cells(CurrentCell).value = (ClientName & " " & "(" & ClientLocation & ")" & " " & ExtraDefinition)
我认为这会把数据放在“工作表”的“B3”位置,但是它把数据放在单元格“AF1”中。
为什么是这样?
谢谢,
玩笑
Cell
不会像你使用的那样被使用; 您必须input用逗号分隔的行和列索引(作为整数)。 因此正确的代码是:
WorkingSheet.Cells(CurrentRow, MyColumn).Value = (ClientName & " " & "(" & ClientLocation & ")" & " " & ExtraDefinition)
另一个select是使用Range
。 例:
WorkingSheet.Range("B3").Value = (ClientName & " " & "(" & ClientLocation & ")" & " " & ExtraDefinition)