在QTP文本框中添加excel / csv文件中的值
在QTP文本框中添加excel / csv文件中的值
大家好,
我有一个手头的Excel文件,我试图将字段复制到文本框中,该文件具有多个列和行中的多个值。 我正在select一行并尝试将这些值插入到文本框中,但无论何时在文本框中input值,下一个值都将覆盖当前值,最后只有一个值。 我希望所有的值都能在文本框中反映出来,所以我可以点击提交button:
代码如下:
Set myxl = createobject("excel.application") myxl.Workbooks.Open "J:\Example1.csv" myxl.Application.Visible = true set mysheet = myxl.ActiveWorkbook.Worksheets("Example1") 'Get the max row occupied in the excel file Row=mysheet.UsedRange.Rows.Count 'Get the max column occupied in the excel file Col=mysheet.UsedRange.columns.count For i= 2 to Row For j= 2 to Col Msgbox mysheet.cells(i,j).value Browser("Some site").Page("Some page").WebEdit("Text Box").Set mysheet.cells(i,j).value + vbLf j = j+7 Next Next 'Save the Workbook myxl.ActiveWorkbook.Save 'Close the Workbook myxl.ActiveWorkbook.Close 'Close Excel myxl.Application.Quit Set mysheet =nothing Set myxl = nothing
以下是我想在文本框中的文件列
![原始文本字段我想运行并提交] [3]
正如你所看到的文本框只接受文件的最后一个值,前2个被删除。 我想从文件中捕获所有的值,并把它们放在文本框中
提前谢谢你 – 网吧
... “获取excel文件中占用的最大列数 列= mysheet.UsedRange.columns.count 对于我= 2行 对于j = 2到Col input = input + mysheet.cells(i,j).value + vbLf j = j + 7 下一个 下一个 浏览器(“某个站点”),页面(“某个页面”),WebEdit(“文本框”),设置input “保存工作簿” ...