Java里面去除Excel的所有公式,同时保留相应公式位置的数值,请问需要怎么实现?

解决方案 »

  1.   

    POI的话sheet.setForceFormulaRecalculation(true);//强制执行excel公式 
    switch (workbook.getCreationHelper().createFormulaEvaluator().evaluateFormulaCell(cell)) {
      case Cell.CELL_TYPE_BOOLEAN:
        cellValue = cell.getBooleanCellValue() == true ? "true": "false";
        break;
      case Cell.CELL_TYPE_NUMERIC:
        cellValue = new DecimalFormat("#.##").format(cell.getNumericCellValue());
        break;
      case Cell.CELL_TYPE_STRING:
        cellValue = cell.getRichStringCellValue().getString();
        break;
      case Cell.CELL_TYPE_BLANK:
        break;
      case Cell.CELL_TYPE_ERROR:
        System.out.println(cell.getErrorCellValue());
        break;
      // CELL_TYPE_FORMULA will never occur
      case Cell.CELL_TYPE_FORMULA:
        break;

      

  2.   


    问你已经用了什么library不。 也就是jar。
      

  3.   

    可以先生成一个sheet,把内容拷进去,然后把带格式的sheet删除掉。