Forum Discussion

axasmgaxa's avatar
axasmgaxa
Occasional Contributor
5 years ago
Solved

Is it possible to get Data Sink to write output to excel file horizontally and not vertically?

Hi Folks,

 

I have soap test that is looping through a few iterations, each time, it writes output via a datasink to an excel file.

The problem is, I would like the data to be written out to cells in a horizontal fashion, (e.g. cells A1, B1, C1) and not in a vertical fashion (e.g. A1, A2, A3) as seems to be default.

 

Many thank in advance for any help,

 

Steven.

  • Thanks to everyone who has responded. 

    I don't think it is possible via datasink. (it certainly maybe possible through Groovy, but I am not very proficient with that as of yet.)

     

    As a work around, I reshuffled the excel sheet so it will expect the response in vertically.

6 Replies

  • As richie has said there is no built in option to do this. Depending on what you plan to do with the spreadsheet I can think of 2 ways that might work. I have not tried either one so I cant guarantee they will work, but it should be a step in the right direction.

     

    The first option is to use the transpose function built into excel. I think you should be able to write the data to one worksheet and use the transpose funtion in another worksheet to flip the data. I'm not sure what versions support this so you might have to see if this will work for the version you are using.

    https://support.office.com/en-us/article/transpose-rotate-data-from-rows-to-columns-or-vice-versa-3419f2e3-beab-4318-aae5-d0f862209744 

     

    The other option is to use groovy. You can read the data from the data sink and then write the data to the next column. I tried doing something similar to this some time ago but scrapped the idea because of how long it took to read and write from a excel file. If you go this route you will need to download the jxl jar and add it to bin/ext.

    https://learnsoapui.wordpress.com/tag/soapui-excel-export/ 

     

    • axasmgaxa's avatar
      axasmgaxa
      Occasional Contributor

      Thanks to everyone who has responded. 

      I don't think it is possible via datasink. (it certainly maybe possible through Groovy, but I am not very proficient with that as of yet.)

       

      As a work around, I reshuffled the excel sheet so it will expect the response in vertically.

      • sonya_m's avatar
        sonya_m
        SmartBear Alumni (Retired)

        Wow! Thank you for reacting so quickly and being so helpful richie, jsheph01, nmrao. This is very much appreciated :smileyhappy:

         

        Hi axasmgaxa, I am glad to hear you found a workaround.

         

         

    • richie's avatar
      richie
      Community Hero

      Hi,

       

      I went through the Data Sink function a couple of days ago trying to find an option that would translate the writing into the file from vertical to horizontal.

      I went through every file type and every option I could see.  Its a looping testcase right, so I even thought about trying a condiitional goto or maybe some other overcomplicated and ridiculous way of doing it (e.g. using a DataSource grid feeding off a Properties step and the DataSink sources the values from the grid) - but I couldn't find an option.

       

      Unless one of the other fellas knows how to do this, I think the option likely to solve this is groovy script (so this counts me out).  I was thinking perhaps allow the DataSink step to write out the values as normal and then use a bit of groovy to translate the values.  I did have a quick search, but I couldn't find any groovy methods that would do this.

       

      Sorry I couldn't be more help,

       

      rich