Read Excel
//classpath: jxl.jar
jxl.Workbook wrk = jxl.Workbook.getWorkbook(new File(sFile));
jxl.Sheet sheet = wrk.getSheet(0);
jxl.Cell[] cellColumn = sheet.getColumn(0);
int rowCount = cellColumn.length;
jxl.Cell[] cellRow = sheet.getRow(0);
int columnCount = cellRow.length;
printOut("The document is: " + rowCount + " rows long | " + columnCount + " columns wide");
// adjust starting row based on input for header
int i = 0;
if ( bHasHeader ) {
i = 1;
}
// loop through all the rows
while ( i <= rowCount ) {
// getCell([column], [row])
String sValueA = sheet.getCell(0, i).getContents();
String sValueB = sheet.getCell(1, i).getContents();
if ( sValueB.contains("Enable") ) {
execute("ALTER USER \"" + sValueA + "\" ENABLED;");
printOut( sValueA + " has been enabled");
} else if ( sValueB.contains("Disable") ) {
execute("ALTER USER \"" + sValueA + "\" DISABLED;");
printOut( sValueA + " has been disabled");
} else {
printOut( "ERROR: could not determine task for " + sValueA + " | " + sValueB);
}
i++;
}