Write data to an Excel file without importing the data to the data table

Writing data to an Excel file without importing the data to the data table

This function will allow you to set data in an external Excel file (specifying the sheet and the cell), without importing the file to the QuickTest data table. The function uses automation objects to create an Excel object.


This function is not part of QuickTest Professional. It is not guaranteed to work and is not supported by Hewlett-Packard Support. You are responsible for any and all modifications that may be required.

PutValueInFile (sfilePath, isheet, irow, icolumn, value)

sfilePathThe path and name of the Excel file.
isheetThe sheet of the Excel file. This can be an index number or the sheet name.
irowThe row number in the table.
icolumnThe column number in the table.
valueThe value to put within the defined cell in the specified sheet.

Function PutValueInFile (sfilePath, isheet, irow, icolumn, value)
   Set ExcelObj = CreateObject("Excel.Application")
   ExcelObj.Workbooks.Open sfilePath
   Set NewSheet = ExcelObj.Sheets.Item(isheet)
   NewSheet.Cells(irow,icolumn) = value
   ExcelObj.ActiveWorkbook.Save
   ExcelObj.Application.Quit
   Set ExcelObj = Nothing
End Function

Example:
filename = "D:\temp\Test.xls"
PutValueInFile filename,1,2,2,"Hello From QTP!"


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值