A POI related code block running dead slow

后端 未结 3 692
再見小時候
再見小時候 2020-12-20 08:23

I have below piece of code block containing loops:

Row row = null;
Cell cell = null;
String dataVal = null;
String[] temp = null;

for (int j = 0; j < thi         


        
3条回答
  •  时光取名叫无心
    2020-12-20 08:39

    try this...

    for (int j = 0; j < this.myDataValues.size(); j++) {
      row = sheet.createRow(rownum++);
      temp = this.finalRowValues.get(j);
    
       for (int i = 0; i < 4; i++) {
           cell = row.createCell(i);
    
           dataVal = temp[i];
    
                if (NumberUtils.isNumber(dataVal)) {
                    double d = Double.valueOf(dataVal);
                    cell.setCellValue(d);
                    cell.setCellType(Cell.CELL_TYPE_NUMERIC);
                    cell.setCellStyle(styles.get("currency"));
                } else if (isValidDate(dataVal)) {
                    cell.setCellValue(dataVal);
                    cell.setCellType(Cell.CELL_TYPE_NUMERIC);
                    cell.setCellStyle(styles.get("date"));
                } else {
                    cell.setCellValue(temp[i]);
                    cell.setCellType(Cell.CELL_TYPE_STRING);
                    cell.setCellStyle(styles.get("data"));
                }
            }
        }
        for (int i = 0; i < 4; i++) {
          sheet.autoSizeColumn(i);
        }
    

提交回复
热议问题