cancel
Showing results for 
Search instead for 
Did you mean: 

Delete First Row In Spreadsheet Via Groovy?

SOLVED
Highlighted
Community Hero

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

 

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta
2 ACCEPTED SOLUTIONS

Accepted Solutions
Highlighted
Community Hero
Highlighted
Community Hero

closing this ticket off as @nmrao sorted me via the other post I made

 

cheers,

 

richie

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

View solution in original post

2 REPLIES 2
Highlighted
Community Hero
Highlighted
Community Hero

closing this ticket off as @nmrao sorted me via the other post I made

 

cheers,

 

richie

if this helped answer the post, could you please mark it as 'solved'? Also if you consider whether the title of your post is relevant? Perhaps if the post is solved, it might make sense to update the Subject header field of the post to something more descriptive? This will help people when searching for problems. Ta

View solution in original post

New Here?
Join us and watch the welcome video:
Announcements
TechCorner Leaderboard
Want a fun and easy way to learn ReadyAPI and show off your skills? Try solving weekly TechCorner challenges and get into the Leaderboard!


Challenge Status

Get a full Raw JMS request

Participate!

Compare an expected JSON value and actual response in Events

Participate!

Fetch value/data from JSON response using Groovy Script

See replies!

Get data from Petstore and add it to Excel sheets

Participate!
Top Kudoed Authors