I have the following code
public boolean processCell(boolean hasData, StringBuffer rowData, Cell cell)
{
switch (cell.getCellType())
{
case Cell.CELL_TYPE_FORMULA:
{
try
{
this.evaluator.clearAllCachedResultValues();
switch (this.evaluator.evaluateFormulaCell(cell))
{
case XSSFCell.CELL_TYPE_NUMERIC:
{
if (DateUtil.isCellDateFormatted(cell))
{
logger.warn(cell.getCellFormula());
rowData.append(dateFormat.format(cell.getDateCellValue()));
hasData = true;
}
else
{
rowData.append(numberFormat.format(cell.getNumericCellValue()));
hasData = true;
}
break;
}
case XSSFCell.CELL_TYPE_STRING:
{
String stringVal = cell.getStringCellValue().trim().replaceAll("
", "");
if (stringVal.trim().equalsIgnoreCase("Total MoU/active customer"))
{
logger.warn("Last - KPI ::" + stringVal);
this.finalRecord = true;
}
rowData.append(stringVal);
hasData = true;
break;
}
case XSSFCell.CELL_TYPE_BOOLEAN:
{
rowData.append(cell.getBooleanCellValue());
hasData = true;
break;
}
case XSSFCell.CELL_TYPE_ERROR:
{
int eval = cell.getErrorCellValue();
if (eval == DIVIDE_BY_ZERO)
rowData.append("0");
hasData = true;
break;
}
case XSSFCell.CELL_TYPE_BLANK:
{
rowData.append("");
hasData = true;
break;
}
}
}
catch (java.lang.IllegalArgumentException e)
{
logger.error(" Formula [ " + (cell.getRowIndex() + 1) + "," + (cell.getColumnIndex() + 1) + " ] "
+ e.getMessage());
rowData.append("CellError");
this.STATUS = FAILURE;
hasData = true;
break;
}
catch (java.lang.IllegalStateException e)
{
logger.error(" Formula [ " + (cell.getRowIndex() + 1) + "," + (cell.getColumnIndex() + 1) + " ] "
+ e.getMessage());
rowData.append("CellError");
this.STATUS = FAILURE;
hasData = true;
break;
}
catch (java.lang.RuntimeException e)
{
this.STATUS = FAILURE;
logger.error(" Formula [ " + (cell.getRowIndex() + 1) + "," + (cell.getColumnIndex() + 1) + " ] "
+ e.getMessage());
rowData.append("MissingFileError");
hasData = true;
break;
}
break;
}
case XSSFCell.CELL_TYPE_BLANK:
{
rowData.append("");
hasData = true;
break;
}
case XSSFCell.CELL_TYPE_NUMERIC:
{
if (DateUtil.isCellDateFormatted(cell))
{
rowData.append(dateFormat.format(cell.getDateCellValue()));
hasData = true;
}
else
{
rowData.append(numberFormat.format(cell.getNumericCellValue()));
hasData = true;
}
break;
}
// Formula evaluation ends here
case XSSFCell.CELL_TYPE_STRING:
{
String stringVal = cell.getStringCellValue().trim().replaceAll("
", "");
if (stringVal.trim().equalsIgnoreCase("Total MoU/active customer"))
{
logger.warn("Last - KPI ::" + stringVal);
this.finalRecord = true;
;
}
rowData.append(stringVal);
hasData = true;
break;
}
case XSSFCell.CELL_TYPE_ERROR:
{
int eval = cell.getErrorCellValue();
if (eval == DIVIDE_BY_ZERO)
rowData.append("0");
hasData = true;
break;
}
case XSSFCell.CELL_TYPE_BOOLEAN:
{
rowData.append(cell.getBooleanCellValue());
hasData = true;
break;
}
}
rowData.append(FIELD_SEPARATOR);
return hasData;
}
when i run the program. in date column i have series of date. the last date without formula is 31/12/2009 its cell reference oj at oj+1 in excel sheet i have 1/1/2010 but in excel sheet i got 29/04/2009 i have printed the formula on this cell and find out that poi 3.6 have wrong cell reference on this. instead of oj+1 its giving NE+1
please help me to resolve the problem
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…