Forum Discussion

abdul_rp's avatar
abdul_rp
Contributor
12 years ago

Invalid Use of Null error while reading data from an Excel sheet

Hi,



I am getting an error saying "
Invalid Use of Null" while reading data from Excel sheet, I am getting this error for the Cell's fromat type Number, whereas I am able to read the data from other formats with any problem. Following is the piece of code I am using to read the data from Excel sheet.



Sub MainTest

 

Set DataDriver = DDT.ExcelDriver("C:\\Scenario.xls","Scenario1")

While Not DataDriver.EOF

MsgBox(DataDriver.Value("INPUTDATA"))

DataDriver.Next

Wend 



End Sub





Regards,

Abdul

  









































3 Replies

  • TanyaYatskovska's avatar
    TanyaYatskovska
    SmartBear Alumni (Retired)

    Hi Abdul,


     


    Try using the aqConvert.VarToStr method to convert data from a cell:




    Set DataDriver = DDT.ExcelDriver("C:\\Scenario.xls","Scenario1")


    While Not DataDriver.EOF


    MsgBox(aqConvert.VarToStr(DataDriver.Value("INPUTDATA")))


    DataDriver.Next


    Wend 



  • sastowe's avatar
    sastowe
    Super Contributor
    In the debugger, what is the value of DataDriver.Value("INPUTDATA")



    And in your spreadsheet, what is the value? Is it empty?



    I am having a problem in which a spreadsheet that I was using early Monday was reading data values fine, but after some unknown action on my part, TC is reporting teh spreadsheet value as null when there is clearly a value there. Is that what you are also experiencing?
  • I had a similar problem with Excel.



    I do not know if it is the same, but I fixed it by checking if the returned value was null (IsNull in vbscript - http://www.w3schools.com/vbscript/func_isnull.asp) and then assigning a default value for empty cells.



    Also, can you attach an example of excel file that causes this problem?