SachinB SachinB - 5 months ago 35
reST (reStructuredText) Question

How to increment ID field stored within a string in excel using JAVA

I have particular scenario where I will be storing JSON in excel cell.
for example

{A="AAA",B="BBB",ID="123", C="CCC",D="DDD"....}

is stored in excel

Now for each execution I want
field to be different(mostly unique). So here I can generate ID using
random number generation
function or I can store some ID in different excel sheet and read it from there.

Does anyone have idea how can we achieve it?


Try to use the random function. Below is the code snippet that might help:

private static int getRandomNumberInRange(int min, int max) {
//min and max is the range of numbers in between the random number is generated
    if (min >= max) {
        throw new IllegalArgumentException("max must be greater than min");

    Random r = new Random();
    return r.nextInt((max - min) + 1) + min;

This may very well solve the issue.