Forum Discussion

TrevorM's avatar
TrevorM
Occasional Contributor
4 years ago
Solved

Copy and paste data from Excel to application under test (javascript)

My application under test is a  desktop app for finance

I need to copy a range of data from an xlsx file to the clipboard and then paste this into my app, i.e. I do not need to read the data into TestComplete e.g. in sheet2 of test.xlsx select and copy a2:j30

 

I can do this by opening Excel, selecting the data and then copying this into my app

This is fine my dev setup, but in my Test environment the servers do not have Excel installed

 

All the Excel examples I have seen seem to be for individual cells rather than a range of cells.

The link below suggest using COM, but the sample is only for reading the data.

https://support.smartbear.com/testcomplete/docs/testing-with/working-with-external-data-sources/excel/working-via-com.html 

 

Is what I am trying to do possible, and if so can anyone give some pointers?

  • hkim5's avatar
    hkim5
    4 years ago

    you would need to scrip that portion, and create a helper function to "copy" the values from the selected cell ranges.

    something like a for loop restricted by the length set by the user dictating the rows to iterate over, appending each cell value to a list or dictionary? I think would be the simplest way to reuse the values again later in another application as your end use would. 

5 Replies

  • BenoitB's avatar
    BenoitB
    Community Hero

    No Excel license on your test environment will be a problem ..

     

    You cannot have data in csv instead of xls(x) ?

     

    If you can, csv are text file so very easy to manipulate without no needs of license, components and so on ..

     

  • Marsha_R's avatar
    Marsha_R
    Champion Level 3

    Are you testing copy/paste function in your app or are you just trying to get the data into your app some way?  I ask because sometimes the easy way for a user to perform the task and the easy way for TestComplete to perform the task are two different things.  What is your actual goal here?

    • TrevorM's avatar
      TrevorM
      Occasional Contributor

      I am trying to replicate how our customers use our app. Typically they will receive data in an Excel spreadsheet and can either import this directly or can copy and paste some of the data.

      I have looked at Excel Object, but as I said in my original post I don't see how to copy a range of cells rather than an individual one.

      • hkim5's avatar
        hkim5
        Staff

        you would need to scrip that portion, and create a helper function to "copy" the values from the selected cell ranges.

        something like a for loop restricted by the length set by the user dictating the rows to iterate over, appending each cell value to a list or dictionary? I think would be the simplest way to reuse the values again later in another application as your end use would. 

  • AlexKaras's avatar
    AlexKaras
    Champion Level 3

    Hi,

     

    the servers do not have Excel installed

    Consider Excel object provided by TestComplete which does not require Excel application to be present on the box.