I use Apache POI to read an excel file (xlsx) This works fine in Eclipse. 30.000 rows and 20 cols are no problem. Loaded after around 5 seconds.
If I generate a runnable JAR File it doesnt process the excel file
try {
soeArraylist.clear();
//JOptionPane.showMessageDialog(null, "SoE Pre Test 1", "Done" , JOptionPane.INFORMATION_MESSAGE);
//Workbook workbook2 = new XSSFWorkbook();
//JOptionPane.showMessageDialog(null, "SoE Pre Test 2", "Done" , JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "SoE Import started 1", "Done" , JOptionPane.INFORMATION_MESSAGE);
FileInputStream excelFile = new FileInputStream(new File(FILE__NAME));
JOptionPane.showMessageDialog(null, "SoE Import started 2 " + FILE__NAME, "Done" , JOptionPane.INFORMATION_MESSAGE);
Workbook workbook = new XSSFWorkbook(excelFile);
JOptionPane.showMessageDialog(null, "SoE Import started 3", "Done" , JOptionPane.INFORMATION_MESSAGE);
Sheet datatypeSheet = workbook.getSheet("SoE");
JOptionPane.showMessageDialog(null, "SoE Import started 4", "Done" , JOptionPane.INFORMATION_MESSAGE);
Iterator<Row> iterator = datatypeSheet.iterator();
JOptionPane.showMessageDialog(null, "SoE Import started 5", "Done" , JOptionPane.INFORMATION_MESSAGE);
DataFormatter formatter = new DataFormatter(Locale.US);
//JOptionPane.showMessageDialog(null, "SoE Import started 6", "Done" , JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "File opened", "Done" , JOptionPane.INFORMATION_MESSAGE);
while (iterator.hasNext()) {
Row currentRow = iterator.next();
........ code removed .......
} catch (FileNotFoundException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "SoE Import FileNotFoundException", "FileNotFoundException" , JOptionPane.INFORMATION_MESSAGE);
} catch (IOException e) {
e.printStackTrace();
JOptionPane.showMessageDialog(null, "SoE Import IOException", "IOException" , JOptionPane.INFORMATION_MESSAGE);
}
So its stopps after SoE Import "started 2" OK it does not stopp but it looks like its processing for ages. After 1 hour still no result.
I tried to create an empty Workbook and this last 20 seconds outside from Eclipse. In Eclipse it is less than 1 second
JOptionPane.showMessageDialog(null, "SoE Pre Test 1", "Done" , JOptionPane.INFORMATION_MESSAGE);
Workbook workbook2 = new XSSFWorkbook();
JOptionPane.showMessageDialog(null, "SoE Pre Test 2", "Done" , JOptionPane.INFORMATION_MESSAGE);
Java is 1.8 in Eclipse and also on the W10 machine. I know there are some similar questions here but non of them have different times between Eclipse and as standalone JAR.
Any Ideas?
What worked for me when I hit this issue in POI 5.0.0 was rolling back to 4.1.2, which had about a 20% performance improvement, but then also selecting "Extract required libraries into JAR" instead of "Package required libraries into JAR" which is the default Eclipse setting, which led to an about 90% improvement over rolling back to 4.1.2.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.