Delete First Row In Spreadsheet Via Groovy?
Hi,
I need to find someway to automate the update of a unique identifier (see below) contained in my .json post request, so that the submissionid value is automatically incremented by a value of 1 each time the test case executes so that I can add my ReadyAPI! project into the jenkins pipeline
e.g. json attribute is as below:
"submissionid" : "1234567890123"
I created another post (link) originally cos I was asking about doing it via inline scripting - but I think I've thought of another way of doing it - hence the reason I've created a new post with a more apt title.
If I created a Excel datasource with the values required (e.g. "1111111100000", "1111111100001", "1111111100002".....up to "1111111130000" etc. <--- this would give me more than enough execution runs) and then I had a script that deleted the FIRST row in the spreadsheet (at the end of the test (teardown script)) - then each time the test was executed, the submissionid used in my .json request would be unique.
I've done a bit of reading there is an 'Apose API' that appears to be reasonably straight forward to delete rows in a spreadsheet, but that looks like it requires money so that's not available.
There is a jxl.jar file that is a sourceforge option for manipulating spreadsheets.....i think this might be the way forward.
I know this is cheeky - cos I'm not coming to you with even an attempt at any code - I just wouldn;t know where to start - I did find the following link which has the following code - but I'm getting nowhere.
/* @Author : Pradeep Bishnoi @Description : Manipulate the data inside an Excel file using jxl api in groovy @Ref : Thanks to Andy Khan for sharing the reference documents about JXL API. */ /* code lines first test step*/ import jxl.* import jxl.write.* WritableWorkbook workbook = Workbook.createWorkbook(new File("d:\\output.xls")) WritableSheet sheet = workbook.createSheet("Worksheet 1", 0) log.info(sheet1.isHidden()) Label label = new Label(0, 2, "Test data in Column A, Row 3"); //column=0=A,row=0=1 sheet.addCell(label); Label label1 = new Label(2, 2, "Column C, Row 3"); sheet.addCell(label1); workbook.write() workbook.close()
would anyone know how to delete the FIRST row in a spreadsheet?
Thanks so much guys - I welcome all/any advice anyone can give me!
richie
- You wouldn't need this as there is solution to
https://community.smartbear.com/t5/SoapUI-Pro/Inline-Scripting-To-increment-a-unique-value-by-1-each/m-p/185589#M42525