用POI为excel单元格写入Large函数问题

用POI为excel单元格写入函数:Large(数值区域参数,第几个最大值参数) 中的数值区域只能用连续的区域值(A1:A5),不可以指定不同区域值(A1,A3,A5),求大神指教啊

HSSFWorkbook wb = new HSSFWorkbook();
        Sheet sheet1 = wb.createSheet("TestSheet");
        sheet1.setForceFormulaRecalculation(true);
        Row row = sheet1.createRow(0);
        Cell cell0 = row.createCell(0);
        cell0.setCellValue(1);
        Cell cell1 = row.createCell(1);
        Row row2 = sheet1.createRow(1);
        Cell cell02 = row2.createCell(0);
        cell02.setCellValue(2);
        //这里使用 String t1 = "LARGE((A1:A5),1)"; 函数就起效果sss
        String t1 = "LARGE((A1,A3,A5),1)";
        cell1.setCellFormula(t1);
        java.io.ByteArrayOutputStream os = new ByteArrayOutputStream();
        wb.write(os);
        java.io.ByteArrayInputStream is = new ByteArrayInputStream(
                os.toByteArray());
        this.downLoad(is, "helloword.xls");
        os.close();

异常信息:

 Caused by: org.apache.poi.ss.formula.FormulaParseException: Parse error near char 9 ',' in specified formula 'LARGE((A1,A3,A5),1)'. Expected ')'
    at org.apache.poi.ss.formula.FormulaParser.expected(FormulaParser.java:219)
    at org.apache.poi.ss.formula.FormulaParser.Match(FormulaParser.java:251)
    at org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1108)
    at org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1079)
    at org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1066)
    at org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1426)
    at org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1526)
    at org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1510)
    at org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1467)
    at org.apache.poi.ss.formula.FormulaParser.Arguments(FormulaParser.java:1051)
    at org.apache.poi.ss.formula.FormulaParser.function(FormulaParser.java:936)
    at org.apache.poi.ss.formula.FormulaParser.parseNonRange(FormulaParser.java:558)
    at org.apache.poi.ss.formula.FormulaParser.parseRangeable(FormulaParser.java:429)
    at org.apache.poi.ss.formula.FormulaParser.parseRangeExpression(FormulaParser.java:268)
    at org.apache.poi.ss.formula.FormulaParser.parseSimpleFactor(FormulaParser.java:1119)
    at org.apache.poi.ss.formula.FormulaParser.percentFactor(FormulaParser.java:1079)
    at org.apache.poi.ss.formula.FormulaParser.powerFactor(FormulaParser.java:1066)
    at org.apache.poi.ss.formula.FormulaParser.Term(FormulaParser.java:1426)
    at org.apache.poi.ss.formula.FormulaParser.additiveExpression(FormulaParser.java:1526)
    at org.apache.poi.ss.formula.FormulaParser.concatExpression(FormulaParser.java:1510)
    at org.apache.poi.ss.formula.FormulaParser.comparisonExpression(FormulaParser.java:1467)
    at org.apache.poi.ss.formula.FormulaParser.unionExpression(FormulaParser.java:1447)
    at org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:1568)
    at org.apache.poi.ss.formula.FormulaParser.parse(FormulaParser.java:176)
    at org.apache.poi.hssf.model.HSSFFormulaParser.parse(HSSFFormulaParser.java:72)
    at org.apache.poi.hssf.usermodel.HSSFCell.setCellFormula(HSSFCell.java:594)

没金币了

1个回答

加上一个引号看看,可能不能识别这种格式

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐