18 January 2026:
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
This forum is now archived and is in read-only mode. Please continue discussions on our improved new Sahi Pro Community forum.
Sahi Pro is an enterprise grade test automation platform which can automate web, mobile, API, windows and java based applications and SAP.
Write to Excel using Sahi Pro excel handling function - getting error
So here is my script:
//Start 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
// End script
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.
//Start 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
// End script
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.
Answers