使用大量行时RowsExceededException

问题描述 投票:0回答:1

我尝试使用java jxl创建一个非常大的ex​​cel文件,一个超过20 GB的文件,问题是当我尝试使一个更大的循环生成更多行时,我有一条错误消息

"jxl.write.biff.RowsExceededException: The maximum number of rows permitted on a worksheet been exceeded
  at jxl.write.biff.WritableSheetImpl.getRowRecord(WritableSheetImpl.java:975)
  at jxl.write.biff.WritableSheetImpl.addCell(WritableSheetImpl.java:951)
  at test2.Test2.main(Test2.java:66)

这是我的代码

try { 
        WritableWorkbook workbook = Workbook.createWorkbook(new File("sortie.xls")); 
        WritableSheet sheet = workbook.createSheet("Premier classeur", 0); 
        //Crée le format d’une cellule 
        WritableFont arial10font = new WritableFont(WritableFont.ARIAL, 12,WritableFont.BOLD, true, UnderlineStyle.NO_UNDERLINE,Colour.BLACK, ScriptStyle.NORMAL_SCRIPT); 
        WritableCellFormat arial10format = new WritableCellFormat(arial10font); 
            //Crée un label à la ligne 0, colonne 0 avec le format spécifique 

            for (int i = 0; i < 100000; i++) {


                    String chars = "abcdefghijklmnopqrstuvwxyz" ;
                    String chars2 ="azertyuiopqsdfghjklmwxcvbn" ;
                    String chars3 ="aqwzsxedcrfvtgbyhnujikolpm" ;
                    String pass = "";
                    String pass2 = "";
                    String pass3 = "";
                    int alava = 6 ;
                    for (int x = 0; x < alava; x++) {
                        int p = (int)Math.floor(Math.random()*26);
                        pass +=chars.charAt(p);
                        pass2 +=chars2.charAt(p);
                        pass3 +=chars3.charAt(p);
                    }
                    Label label = new Label(0, i, pass); 
                    Label label2 = new Label(1, i, pass2); 
                    Label label3 = new Label(2, i, pass3); 
                    //Crée un label à la ligne 2, colonne 0 sans style prédéfini 
                    //Label label2 = new Label(0, 2, "Résultat"); 
                    //Ajout des cellules 
                    sheet.addCell(label); 
                    sheet.addCell(label2);
                    sheet.addCell(label3);


        }

            //Ajout d’une cellule ligne 2, colonne 1 
            //Number number = new Number(1, 2, 3.1459); 
            //sheet.addCell(number); 
            //Ajout d’une image ligne 4, colonne 0 
            //Taille de l’image : 6 lignes et 2 colonnes 
            //WritableImage image = new WritableImage(0, 4, 2, 6,new File("Logo-Labo-Sun.png")); 
            //sheet.addImage(image); 
            //Ecriture et fermeture du classeur 
            workbook.write(); 
            workbook.close(); 
            } catch (RowsExceededException e1) { 
            e1.printStackTrace(); 
            } catch (WriteException e1) { 
            e1.printStackTrace(); 
            } catch (IOException e) { 
            e.printStackTrace(); 
        }finally{ 
        System.out.println("Le fichier \"sortie.xls\" à été généré correctement."); 

    } 
    // TODO code application logic here
}
java csv jxl
1个回答
© www.soinside.com 2019 - 2024. All rights reserved.