Reading in a random cell value from excel sheet

后端 未结 2 880
孤街浪徒
孤街浪徒 2021-01-22 03:31

I have stored =RANDBETWEEN(10, 20) in my excel sheet, this formula generates random values in the excel sheet between 10 to 20. I need to read this 5 random values

2条回答
  •  生来不讨喜
    2021-01-22 04:12

    You use i to query the same cell (A1) five times. This value is calculated upon opening / refreshing the worksheet in Excel. Why do you think that querying the same cell in rapid succession would result in something different each time?

    I'm not sure why you're relying on Excel for random numbers. Is there a reason you can't generate these in Java directly instead? For example:

    // Assuming 20 is your max, 10 your min
    Random random = new Random();
    int yourRandomNumber = random.nextInt((20 - 10) + 1) + 10;
    

提交回复
热议问题