if (_book == null) {
if (_src == null) {
throw new UiException("Must specify the src of the spreadsheet to create a new book");
}
try {
Importer importer = _importer;
if(importer == null){
importer = new ExcelImporter();
}
if(importer instanceof ExcelImporter){
URL url = null;
if(_src.startsWith("/")){//try to load by application context.
File file = new File(Executions.getCurrent().getDesktop().getWebApp().getRealPath(_src));
if(file.exists()){
url = file.toURI().toURL();
}
}
if(url==null){//try to load from class loader
url = new ClassLocator().getResource(_src);
}
if(url==null){//try to load from file
File f = new File(_src);
if(f.exists()){
url = f.toURI().toURL();
}
}
if(url==null){
throw new UiException("resource for "+_src+" not found.");
}
_book = ((ExcelImporter)importer).imports(url);
}else{
_book = importer.imports(_src);
}
_book.addSSDataListener(_dataListener);
_book.addVariableResolver(_variableResolver);
_book.addFunctionMapper(_functionMapper);