Forum Discussion

tinauser's avatar
tinauser
Frequent Contributor
14 years ago

Reading from xls file for some cell

Hi there,

I have made a very simple DDT, and it seems TC cannot read it.

I tried to post a log with the content of column 2 without success. Can you tell me why?


6 Replies

  • Hi,


    To figure out what's wrong, we'll need to look into your script code. Could you please attach it here? Does your script generate any errors while playing it back ? If any error occurs, on which script line does it occur and what's the exact error text?

     

    Also, please specify what TestComplete and Excel versions are you using?


    Thanks in advance.

    Ann

  • tinauser's avatar
    tinauser
    Frequent Contributor
    Hi, thanks for the answer.

    There is not really much code here: the translation of the keyword test is as follows:

    function Test2()

    {

      Project.Variables.myXlsTable.Reset();

      for(; !Project.Variables.myXlsTable.IsEOF();)

      {

        //Posts an information message to the test log.

        Log.Message("", Project.Variables.myXlsTable.Value("Msg"));

        Project.Variables.myXlsTable.Next();

      }

    }



    where myXlstable is the .xls table attached before. some messages are trunkated.



    TC version: 8.70.727

    Excel version: 14.0 (2010 professional plus)
  • Hi,


    Could you please clarify how you populated the myXlsTable variable in your project? Is it a Project or ProjectSuite variable?


    I have created a ProjectSuite variable and the following script code works correctly with your Excel table:



    function Test2()

    {

      ProjectSuite.Variables.myXlsTable.Reset();

      while(!ProjectSuite.Variables.myXlsTable.IsEOF())

      {

      Log.Message(ProjectSuite.Variables.myXlsTable.Value("Msg"));

      ProjectSuite.Variables.myXlsTable.Next();

      }


    Ann

  • tinauser's avatar
    tinauser
    Frequent Contributor
    Hallo Ann,

    I did not write a script in this case, I just did a data driven loop within a simple keyword test.

    The code you see is just the code automatically generated by test complete:

    1. I attached a log action

    2. Rightclick->make Datadriven loop...->used the wizard (create new variable, browse for the xls file, select the worksheet).

    3.Modified the log so that it uses value from the table in the additional information.

    I think that differently from the script, in the keyword test the DBobject is a keywordtest variable.



    Are you sure it work properly?Look for instance at the message that should be read in row 16: is that complete?
  • Hi,


    Oh, well, I got it. You get all the data but it is truncated. This is a known issue of the Excel ODBC driver. It can truncate cell data to 255 symbols, if the first 8 rows were shorter than 256 characters. See a description of this issue here.


    I hope this information helps.

  • tinauser's avatar
    tinauser
    Frequent Contributor
    Yes, very much indeed.

    So it is enough to insert a dummy row and start the DDT from row 2.

    Thanks!