-
Notifications
You must be signed in to change notification settings - Fork 138
Open
Labels
Description
i am uploading excel file with record count of 10K. when i use foreach, its working properly. but when i try to use parallel.forEach(), its not read all the values from excel.
the following code is not reading all the data from excel. its so inconsistent.
try (InputStream is =new FileInputStream(new File(fileLocation)); ReadableWorkbook wb = new ReadableWorkbook(is)) {
Sheet sheet = wb.getFirstSheet();
`` try (Stream<Row> rows = sheet.openStream()) {
rows.skip(2).parallel().forEach(r -> {
BigDecimal bDec = r.getCellAsNumber(0).orElse(null);
if(bDec!=null)
obj.add(bDec.intValue());
});
}
}
Please correct me if i am doing anything wrongly.