Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
778 views
in Technique[技术] by (71.8m points)

java - Could not resolve external workbook name 'excel_file_name.xlsx'. Workbook environment has not been set up

My Spring Boot project using Apache Poi to read data from excel file.

i use FormulaEvaluator to calculate the value of cell

FormulaEvaluator formulaEvaluator = workbook.getCreationHelper().createFormulaEvaluator();
formulaEvaluator.evaluateFormulaCell(cell)

I get the error

Could not resolve external workbook name 'excel_file_name.xlsx'. Workbook environment has not been set up.

How to resolve this issue ?


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I have fixed this issue by using method getCachedFormulaResultType as the document org.apache.poi.ss.usermodel.Cell

CellType getCachedFormulaResultType()

Only valid for formula cells

Returns: one of (CellType.NUMERIC, CellType.STRING, CellType.BOOLEAN, CellType.ERROR) depending on the cached value of the formula

i think method evaluateFormulaCell not work because the formular reference to another workbook


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...