Forum Discussion

surajgr's avatar
surajgr
Occasional Contributor
11 years ago

Multiple DataSink Steps to Same Excel File But Diff Sheets

Hi all,

One of my test cases contain 3 datasink test steps. I want each of these steps to write out data into the same Excel file but different worsheets.
I thought the solution was obvious - Set "File" and "Out File" fields to the same Excel file path for all 3 datasinks but specify 3 different worksheets in the "Worksheet" field.

But what happens when run the test case is that, the first datasink writes the data to the first sheet, second datasink removes data in the first sheet and writes data into the second sheet and finally, the third one removes data in the first two sheets and writes its own data to the third worksheet.

The only data that is really retained, arethe headers I added to the file PRIOR to executing the test case.

So currently I am maintaining three seperate Excel files, one for each datasink.

Is this the only solution or is there someway to make each datasink write out data into seperate sheets without removing any existing data, written out by prior datasinks?

4 Replies

  • SmartBear_Suppo's avatar
    SmartBear_Suppo
    SmartBear Alumni (Retired)
    I don't think there's a way to do that in the same test case. The problem is there with excel too. For example, try:
    - open a CSV file in Excel and keep it open
    - open the same file in Notepad and try to change it and save it

    You'll see that the first instance of Excel will hold the lock on it to prevent changes.

    I'd try, if possible, to break the steps out into different test cases and execute the test suite.

    Michael Giller
    SmartBear Software
  • surajgr's avatar
    surajgr
    Occasional Contributor
    Hi Michael,

    Thanks for the reply. I will try splitting the steps into multiple test cases or continue using seperate DataSinks.

    But I dont think your example with Notepad and Excel is a good analogy. Since the DataSinks execute one AFTER the other and not at the sametime, a more realistic analogy of the scenario would be,

    1. Open CSV in Excel, make changes, save and close.
    2. Open CSV in Notepad, make changes, save and close.

    ... in which case everything work fine, unlike our DataSinks.

    Moreover, in the scenario you described, Notepad will not be able to write to the file at all. Where as with DataSinks, the second DataSink overwrites whatever data the first one saved.

    Suraj
    • Adam2017's avatar
      Adam2017
      Senior Member

      Is there a workaround for this without having to maintain multiple excel files??