我一直在编写一些代码来从应用程序中提取数据并将其解析为电子表格。
我的电子表格如下所示:
Scenario ClientName ClientNumber
5555 Smith s0001
6776 Charles d6666
我有这个代码:
Dim ObjExcel As New Excel.Application Dim sWindow As New WinWindow ObjExcel.Visible = False Dim stext As String
ObjExcel.Workbooks.Open("c:\data\calcresults.xlsx")
Dim ObjWS As Excel.Worksheet = ObjExcel.Worksheets("IP")
Dim iNextRow As Integer = ObjWS.UsedRange.End(Excel.XlDirection.xlDown).Row + 1
ObjWS.Cells(iNextRow,1 ) = "d66666"
ObjWS.Cells(iNextRow, 2) = "s77898"
想使用列名而不是索引,例如:
ObjWS.Cells(iNextRow,"Scenario" ) = "新行数据,第一列"
有什么想法我该怎么做?