zoukankan      html  css  js  c++  java
  • QTP操作excel文档

    对于QTP操作excel的大前提是,保证组建服务里的DCOM配置里存在 microsoft excel application ,具体的查看方式是,在运行框中输入dcomcnfg,然后会打开组件服务的窗口,选择组件服务,计算机,我的电脑,DCOM配置,可以在里面查找存不存在microsoft excel application,存在的话,恭喜你,不出意外是可以对excel文档进行操作了。

    下面为具体的操作代码。

    option  explicit 
    Dim excel 
    Set excel = createObject("excel.application")
    excel.Visible = true
    Dim excelBook 
    '打开工作簿
    Set excelBook = excel.Workbooks.Open("C:Documents and SettingsAdministrator桌面	est.xls")
    '指定工作的表格
    Dim excelSheet 
    Set excelSheet = excelBook.Sheets("Sheet1")
    '取出表格里有效的行数
    Dim rowCount
    rowCount= excelSheet.usedRange.rows.count
    '取出表格里有效的列数
    Dim  columnCount
    columnCount=excelSheet.usedRange.columns.count
    '取出每个单元格的值
    Dim cellValue,i,j
    cellValue = ""
    For  i = 1 to rowCount
    	For  j =1 to columnCount
    			cellValue = excelSheet.cells(i,j) & cellValue
    	Next
    Next
    'msgbox(cellValue)
    '向excel中写入数据
    Dim content
    content = "this is a new cell"
    excelSheet.cells(rowCount+1,1) = content
    '保存写入的数据
    excelBook.Save
    excelBook.Close
    excel.Quit
    Set excelSheet = nothing
    Set excelBook = nothing
    Set excel = nothing
    
  • 相关阅读:
    d is undefined错误
    $ is not defined错误类型
    jsonp从服务器读取数据并且予以显示
    jquery来跨域提交表单
    json和jsonp的使用格式
    Compaction介绍
    mysql操作
    DNS安装配置
    FLUSH TABLES WITH READ LOCK 和 LOCK TABLES 之种种
    执行安装redis报错undefined reference to `__sync_add_and_fetch_4'
  • 原文地址:https://www.cnblogs.com/huang1990/p/3682725.html
Copyright © 2011-2022 走看看