Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/71.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 使用apache poi读取excel文件时发生异常_Java_Excel_Apache Poi - Fatal编程技术网

Java 使用apache poi读取excel文件时发生异常

Java 使用apache poi读取excel文件时发生异常,java,excel,apache-poi,Java,Excel,Apache Poi,我正在阅读两份excel表格,共97000行。当我在eclipse上运行程序时,会出现此异常。它卡在92865行。代码中是否有问题,或者是内存配置问题。iteratormaster是第二个工作簿的迭代器。stringSet是一个哈希集。当我增加堆大小时,它运行良好。当我创建一个jar并将其分发到其他机器上时,它不起作用。有永久的解决办法吗 while (iteratormaster.hasNext()){ //jLabel5.setText("Processi

我正在阅读两份excel表格,共97000行。当我在eclipse上运行程序时,会出现此异常。它卡在92865行。代码中是否有问题,或者是内存配置问题。iteratormaster是第二个工作簿的迭代器。stringSet是一个哈希集。当我增加堆大小时,它运行良好。当我创建一个jar并将其分发到其他机器上时,它不起作用。有永久的解决办法吗

       while (iteratormaster.hasNext()){
           //jLabel5.setText("Processing record "+qw+" out of"+ total+ " "+ "(" +   (qw/total)*100+"%");
          Row rowmaster =   iteratormaster.next();
              int qw1= rowmaster.getRowNum();
               if (qw1%1500==0){
               //jProgressBar1.setValue(((qw+n)/total)*100);
               //    Thread.sleep(500);
               jLabel11.setText("Processing record "+(qw1+n)+" out of "+ total);
               jLabel11.paintImmediately(jLabel11.getVisibleRect());
               }
          Cell media1 = rowmaster.getCell(5,Row.CREATE_NULL_AS_BLANK);
          String gandu=media1.toString();
          b.add(gandu);
              //sorted.add(gandu);
          Cell cellmaster0 = rowmaster.getCell(4,Row.CREATE_NULL_AS_BLANK);
          if (stringSet.contains((cellmaster0).toString()))
          {
              rowindexa++;

              cellindexa=-1;
              Row rowa=sheeta.createRow(rowindexa);
              //Iterator<Cell> cellmaster = rowmaster.iterator();
              for (int cn=0;cn<rowmaster.getLastCellNum();cn++){
                  cellindexa++;
                  Cell cellmaster1= rowmaster.getCell(cn, Row.CREATE_NULL_AS_BLANK);
                  String aap = cellmaster1.toString();
                  Cell cella =rowa.createCell(cellindexa);
                  cella.setCellValue(aap);
                              if (aap.indexOf("\t")!=-1){
                              System.out.println(aap);}
              }


          }
          else {
              rowindextemp++;
              cellindextemp=-1;
              Row rowb=sheettemp.createRow(rowindextemp);
              //Iterator<Cell> celltemp1 = rowmaster.cellIterator();
              for (int cn1=0;cn1<rowmaster.getLastCellNum();cn1++){
                  cellindextemp++;
                  Cell celltemp2 = rowmaster.getCell(cn1,Row.CREATE_NULL_AS_BLANK);
                  String congress=celltemp2.toString();
                  Cell cellb = rowb.createCell(cellindextemp);
                  cellb.setCellValue(congress);
              }

              }


          }







Exception in thread "AWT-EventQueue-0" java.lang.OutOfMemoryError: GC overhead limit exceeded
at org.apache.xmlbeans.impl.store.Saver$TextSaver.resize(Saver.java:1592)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.preEmit(Saver.java:1223)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.emit(Saver.java:1144)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.emitElement(Saver.java:926)
at org.apache.xmlbeans.impl.store.Saver.processElement(Saver.java:456)
at org.apache.xmlbeans.impl.store.Saver.process(Saver.java:307)
at org.apache.xmlbeans.impl.store.Saver$TextSaver.saveToString(Saver.java:1727)
at org.apache.xmlbeans.impl.store.Cursor._xmlText(Cursor.java:546)
at org.apache.xmlbeans.impl.store.Cursor.xmlText(Cursor.java:2436)
at org.apache.xmlbeans.impl.values.XmlObjectBase.xmlText(XmlObjectBase.java:1455)
at org.apache.poi.xssf.model.SharedStringsTable.getKey(SharedStringsTable.java:130)
at org.apache.poi.xssf.model.SharedStringsTable.addEntry(SharedStringsTable.java:176)
at org.apache.poi.xssf.usermodel.XSSFCell.setCellValue(XSSFCell.java:350)
at org.apache.poi.xssf.usermodel.XSSFCell.setCellValue(XSSFCell.java:320)
at defg.jButton4ActionPerformed(defg.java:1068)
at defg.access$9(defg.java:942)
at defg$9.actionPerformed(defg.java:539)
at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:2018)
at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2341)
at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:402)
at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:259)
at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:252)
at java.awt.Component.processMouseEvent(Component.java:6505)
at javax.swing.JComponent.processMouseEvent(JComponent.java:3320)
at java.awt.Component.processEvent(Component.java:6270)
at java.awt.Container.processEvent(Container.java:2229)
at java.awt.Component.dispatchEventImpl(Component.java:4861)
at java.awt.Container.dispatchEventImpl(Container.java:2287)
while(iteratormaster.hasNext()){
//jLabel5.setText(“处理记录”+qw+”,共“+total+”+”(“+(qw/total)*100+”%);
行rowmaster=iteratormaster.next();
int qw1=rowmaster.getRowNum();
如果(qw1%1500==0){
//jProgressBar1.设定值((qw+n)/总计)*100;
//睡眠(500);
jLabel11.setText(“处理记录”+(qw1+n)+总数中的“+”;
jLabel11.paintInstance(jLabel11.getVisibleRect());
}
Cell media1=rowmaster.getCell(5,Row.CREATE\u NULL\u为\u BLANK);
字符串gandu=media1.toString();
b、 加(甘都);
//排序。添加(甘都);
Cell cellmaster0=rowmaster.getCell(4,行。创建\u空\u为\u空);
if(stringSet.contains((cellmaster0.toString()))
{
rowindexa++;
cellindexa=-1;
rowa行=sheeta.createRow(rowindexa);
//迭代器cellmaster=rowmaster.Iterator();

对于(int cn=0;cn尝试增加项目的内存-


在Eclipse中,右键单击您的项目>运行方式>运行配置>参数选项卡>虚拟机参数部分>添加-Xms512M-Xmx1024M或>应用

没关系。但是如果用它制作jar,我也会面临同样的问题。所以没用JVM的堆大小是多少?您是否尝试过增加它?当我增加它时,它会起作用,但如果我创建一个jarjar溢出并在其他机器上运行。它失败了。永久解决方案?您可以在一台机器上设置默认的JVM堆大小-只要在任何地方都设置,就可以了。(安装通常会设置一个非常低的值)我正在使用SET _JAVA_OPTIONS=-Xms512m-Xmx1024m在32位机器上增加堆大小,但仍然不起作用。我应该设置什么堆大小。事实上,它在过程中很早就被卡住了。您是否尝试过阅读该文件?