Apache POI 4.1.2 Working much slower on java 1.8 then java 11

Viewed 156

The application sends data to Excel. On a computer with Java 1.8, it takes 5 minutes to load this data. on Java 11, data is read in a second. What could be the reason? I tried apache poi 4.1.2 and 5.2.2 without any sucess

code that sends data to excel and then runs the script in vba :

                    // Creating file object of existing excel file
                    File xlsxFile1 = new File(".\\HUB.xlsm");            
                    //New records to update in excel file
                    String telefonbezstafki = sraka.telefon.replaceAll("\\s","");
                    Object[][] nowedane ={{sraka.name.replaceAll("-"," ")},
                            {sraka.2name.replaceAll("-"," ")},
                            {phonebezstafki },
                            {sraka.mail},
                            {Konto_Stars}};
                    
                        //Creating input stream
                        FileInputStream inputStream1 = new FileInputStream(xlsxFile1);
                        System.out.println("stworzenie xlm" );
                        //Creating workbook from input stream
                        Workbook workbook = WorkbookFactory.create(inputStream1);
                        System.out.println("Workbook workbook =WorkbookFactory.create(inputStream1);" );
                        //Reading first sheet of excel file
                        Sheet sheet = workbook.getSheetAt(0);
                        System.out.println("Sheet sheet = workbook.getSheetAt(0);" );
                        //Getting the count of existing records
                    
                        int rowCount = sheet.getLastRowNum();
                        System.out.println("int rowCount = sheet.getLastRowNum();" );

                        //Iterating new data to update
                        for (Object[] student : nowedane) {

                            //Creating new row from the next row count
                            Row row = sheet.createRow(++rowCount);

                            int columnCount = 0;

                            //Iterating student informations
                            for (Object info : student) {

                                //Creating new cell and setting the value
                                Cell cell = row.createCell(columnCount++);
                                if (info instanceof String) {
                                    cell.setCellValue((String) info);
                                } else if (info instanceof Integer) {
                                    cell.setCellValue((Integer) info);
                                }
                            }
                        }
                        //Close input stream
                        inputStream1.close();

                        //Crating output stream and writing the updated workbook
                        FileOutputStream os = new FileOutputStream(xlsxFile1);
                        workbook.write(os);

                        //Close the workbook and output stream
                        workbook.close();
                        os.close();

                    
0 Answers
Related