poi写入excel出现内容混淆

前几天做项目时,引用了poi做ecxel读写,然后小数据量的时候没啥问题,但是数据量一大,就出现了有些行,内容合在一起了.

代码如下

   XSSFRow rowhot = sheet.createRow(a);
    String[] value = errorData.getData();
    String msg = errorData.getMsg();
    int i = 0;
    for (String s : value) {
        rowhot.createCell(i).setCellValue(s);
        i += 1;
    }
    rowhot.createCell(6).setCellValue(msg);
    a += 1;

后来加了个锁后,就一切正常了

synchronized ("error") {
    XSSFRow rowhot = sheet.createRow(a);
    String[] value = errorData.getData();
    String msg = errorData.getMsg();
    int i = 0;
    for (String s : value) {
        rowhot.createCell(i).setCellValue(s);
        i += 1;
    }
    rowhot.createCell(6).setCellValue(msg);
    a += 1;
}

 

你可能感兴趣的:(自己遇到的BUG)