Read formula from excel using apache poi in java

Read formula from excel using apache poi in java:

import org.apache.poi.hssf.usermodel.HSSFDateUtil;
import org.apache.poi.ss.usermodel.*;
import java.util.Date;
//declarations of excel and class stuff

public String readFormuleFromRowOnIndex(Row currentRow, Workbook workbook, int index){
	FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
	Cell currentCell = currentRow.getCell(index);
	CellValue cellValue = evaluator.evaluate(currentCell);
	if (cellValue.getCellType() == CellType.FORMULA) {
		String formule = currentCell.getCellFormula();
	}
	return null;
}

public Object calculateFormuleFromRowOnIndex(Row currentRow, Workbook workbook, int index){
	//the type of the formule value will be converted to the value using evaluator
	FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
	Cell currentCell = currentRow.getCell(index);
	CellValue cellValue = evaluator.evaluate(currentCell);
	if (currentCell != null && cellValue != null) {
		if (cellValue.getCellType() == CellType.STRING) {
			String value = cellValue.getStringValue();
			return value;
		} else if (cellValue.getCellType() == CellType.NUMERIC) {
			if (HSSFDateUtil.isCellDateFormatted(currentCell)) {
				Date value = currentCell.getDateCellValue();
				return value;
			} else {
				Double value  = ((Double) cellValue.getNumberValue());
				return value;
			}
		} else if (cellValue.getCellType() == CellType.FORMULA) {
			//this is not going to be executed in order to get the formule use the first function
			String value = cellValue.getStringValue();
			return value;
		} else if (cellValue.getCellType() == CellType.BOOLEAN) {
			Boolean value = ((Boolean) cellValue.getBooleanValue());
			return value;
		}
	}
	return null;
}

The Formule is formatted to the right type of the formule execution

Maven dependencies:

<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi</artifactId>
    <version>4.0.0</version>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml</artifactId>
    <version>4.0.0</version>
</dependency>
<dependency>
    <groupId>org.apache.poi</groupId>
    <artifactId>poi-ooxml-schemas</artifactId>
    <version>4.0.0</version>
</dependency>