0

So here is my script:

//Get a handle to the Excel sheet 
var $db = _getExcel("C:\\Users\\datasource.xlsx","Sheet1");

//Get Data
var $rs=$db.getData();

//Set a random number to append to this group of usernames
var $rand= null;
_set($rand,_random(1000000));

//For each class code in Excel datasource, create a new account
for(var $i=1; $i<$rs.length; $i++){
var $classcode = $rs[$i][0];        //column 0 is class codes
CreateEnrollmentPreview($classcode,$rand)

var $rs=$db.set([$i],[3],$classcode + "_" + $rand + "@domain.com");
}  // this line fails

Something about that $db.set function in the last line is failing with the error Wrapped java.lang.NullPointerException. I've tried passing those indexes with and without brackets but always get the same result. Anyone know where I'm going wrong?

All current help online seems to use the old method of treating an Excel file like a database with the _dbGet function.

kyoob
  • 499
  • 5
  • 23

1 Answers1

0

Figured it out. I had the Excel file open in another window. When I closed it and tried again this worked just fine.

kyoob
  • 499
  • 5
  • 23