【发布时间】:2021-02-01 20:51:02
【问题描述】:
我使用 Apache POI 读取 excel 文件 (xlsx) 这在 Eclipse 中运行良好。 30.000 行和 20 列没问题。大约 5 秒后加载。
如果我生成一个可运行的 JAR 文件,它不会处理 excel 文件
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);
}
所以在 SoE Import "started 2" 之后它就停止了 好的,它不会停止,但看起来它的处理时间很长。 1小时后仍然没有结果。
我试图在 Eclipse 之外创建一个空的工作簿和最后 20 秒。在 Eclipse 中不到 1 秒
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 在 Eclipse 和 W10 机器上是 1.8。 我知道这里有一些类似的问题,但没有一个在 Eclipse 和作为独立 JAR 之间有不同的时间。
有什么想法吗?
【问题讨论】:
标签: java excel apache-poi