}
return readStatus;
}
public ReadStatus readAllPerSheet(InputStream is, Map<String, Object> beans) {
ReadStatus readStatus = new DefaultReadStatus();
readStatus.setStatus(ReadStatus.STATUS_SUCCESS);
try {
Workbook wb = WorkbookFactory.create(is);
if(definition.getExcelSheets().size() == 0){
readStatus.setStatus(ReadStatus.STATUS_SETTING_ERROR);
readStatus.setMessage("No sheet definition found");
}else{
//Only first ExcelSheet Definition will be used
ExcelSheet sheetDefinition = definition.getExcelSheets().iterator().next();
Map<String,List<Object>> cacheMap = new HashMap<String, List<Object>>();
for(String key: beans.keySet()){
if(beans.get(key) != null)
cacheMap.put(key, new ArrayList<Object>());
}
for(int i = 0; i< wb.getNumberOfSheets(); i++){
Map<String, Object> clonedBeans = cloneMap(beans);
readSheet(wb,i, sheetDefinition, new OgnlStack(clonedBeans), readStatus);
for(String key: clonedBeans.keySet())
cacheMap.get(key).add(clonedBeans.get(key));
}
for(String key: beans.keySet()){
if(cacheMap.containsKey(key)){
beans.put(key, cacheMap.get(key));
}else{
beans.put(key, null);
}
}
}
} catch (IOException e) {
readStatus.setStatus(ReadStatus.STATUS_READ_FILE_ERROR);
} catch (InvalidFormatException e) {
readStatus.setStatus(ReadStatus.STATUS_READ_FILE_ERROR);
} catch (InstantiationException e) {
e.printStackTrace();
readStatus.setStatus(ReadStatus.STATUS_SYSTEM_ERROR);
readStatus.setMessage("New Instance Error");
} catch (IllegalAccessException e) {
e.printStackTrace();
readStatus.setStatus(ReadStatus.STATUS_SYSTEM_ERROR);
readStatus.setMessage("New Instance Error");
}
return readStatus;
}