2014-06-10 6 views
0

하나의 열에서 소수의 셀을 합산하는 xls 수식을 작성해야합니다. 그 공식의 XLS의 출력은 모양 :org.apache.poi xls의 수식 작성하기

SUM(F5;F9;F13;F16) 

나는 org.apache.poi 라이브러리에 그 공식을 만들었습니다.

[FormulaParseException: Parse error near char 6 ';' in specified formula 'SUM(F5;F9;F13;F16)'. Expected ',' or ')'] 

당신은 나에게 어떤 조언을 줄 수 :

Cell cell = rowSum.createCell(j); 
cell.setCellType(Cell.CELL_TYPE_NUMERIC); 

// column number like (A or B) in excel to use in formula 
String x = CellReference.convertNumToColString(j); 
cell.setCellType(HSSFCell.CELL_TYPE_FORMULA); 

// for total sum row 
String totalSumFormula = "SUM("; 

for(int s=0; s<sumRowNumbers.size(); s++) { 
int tempSumRowNumber = sumRowNumbers.get(s); 
tempSumRowNumber++; 
    totalSumFormula += (x + tempSumRowNumber); 

    if(s+1 != sumRowNumbers.size()) { 
     totalSumFormula += ";"; 
} else { 
    totalSumFormula += ")"; 
    } 
} 
cell.setCellFormula(totalSumFormula); 

하지만 unfortunatelly 나는 내가 이해하지 못할 오류는 무엇입니까? 어떻게 처리할까요?

답변

0

안녕하세요. 제 문제에 대한 해결책을 찾았습니다. seperator를 사용해야합니다 : ","대신 ";".

이제는 매력처럼 작동합니다. 도서관에서 적절한 생성 식 :

SUM(F5,F9,F13,F16) 

엑셀 파일에 공식을 생성

=SUM(F5;F9;F13;F16) 
+1

파일 형식이 오직 Excel에서 때때로 디스플레이를 localises 경우에도 미국 스타일 구분 기호/문자열에서 작동 – Gagravarr