We used the below code with calculateFormula()to get the value from the excel sheet.But we are not able to fetch the correct value.
private Object getValueByIndex(int attributeIndex, CellValueType valueType)
{
if (!isValidRow())
{
// VEH00059535 - Lates Aspose changes - start
throw new IllegalArgumentException(" The row pointer [" + rowIndex + “] for the page Id + [”
+ cellSetMetaData.getContainedPageId() + “] with Range Name: [” + sectionRange.getName()
+ “] is invalid.”);
// VEH00059535 - Lates Aspose changes - end
}
if (attributeIndex > getAttributeCount())
{
// VEH00059535 - Lates Aspose changes - start
throw new IllegalArgumentException(" The attributeIndex [" + attributeIndex + "] for the page Id + " + “[”
+ cellSetMetaData.getContainedPageId() + “] with Range Name: [” + sectionRange.getName()
+ “] is invalid.”);
// VEH00059535 - Lates Aspose changes - end
}
Object returnData = null;
// The row and the column indexes that are decided based on orientation.
int absoluteRowId = getAbsoluteRowId(attributeIndex);
int absoluteColumnId = getAbsoluteColumnId(attributeIndex);
// VEH00059535 - Lates Aspose changes - start
sectionRange.getWorksheet().getWorkbook().calculateFormula();
Cell cell = sectionRange.getWorksheet().getCells().checkCell(absoluteRowId, absoluteColumnId);
/Style style = cell.getStyle();
style.setNumber(1);
StyleFlag flag = new StyleFlag();
flag.setNumberFormat(true);
cell.setStyle(style, flag);/
//Cell cell = sectionRange.getCellOrNull(absoluteRowId - sectionRange.getFirstRow(), absoluteColumnId - sectionRange.getFirstColumn());
// VEH00059535 - Lates Aspose changes - end
if (cell != null)
{
// Based on the type of value expected the
// same is being returned.
if (CellValueType.NATIVE.equals(valueType))
{
returnData = cell.getValue();
}
else if (CellValueType.FORMATTED.equals(valueType))
{
returnData = cell.getStringValue();
}
}
// convert the Null to the blank string otherwise NULL will be displayed
// on the screen.
if (returnData == null)
{
returnData = “”;
}
return returnData;
}