±âŸ(framework)
2017.04.27 / 21:35

poi ¶óÀ̺귯¸®·Î Excel File Spread Sheet Cell Àбâ

Scoda
Ãßõ ¼ö 218

½Ä(formula)À¸·Î µÈ ¿¢¼¿ ÆÄÀÏ ¾ÈÀÇ cell °ªÀ» Àд ¹æ¹ý


±×³É cell.getStringCellValue()  ÀÌ·± ½ÄÀ¸·Î È£ÃâÇϸé Cannot get a text value from a numeric formula cell ¿¡·¯°¡ ³­´Ù.


cellValue = cell.getCellFormula(); 

ÀÌ·¸°Ô Çϸé "F2/D2" ÀÌ·± formula ¹®ÀÚ¿­À» ¾ò´Â´Ù.


½Ä(formula)¸¦ °è»êÇÑ °ªÀ» ¾ò±â À§Çؼ­´Â ´ÙÀ½°ú °°ÀÌ ÇØ¾ß ÇÑ´Ù.


import org.apache.poi.ss.usermodel.Cell;

import org.apache.poi.ss.usermodel.CellValue;

import org.apache.poi.ss.usermodel.FormulaEvaluator;

import org.apache.poi.ss.usermodel.Workbook;


FormulaEvaluator formulaEval = workbook.getCreationHelper().createFormulaEvaluator();

String cellValue = "";

if( cell != null ) {

CellValue evaluate = formulaEval.evaluate(cell);

if( evaluate != null )

cellValue = evaluate.formatAsString();

}


[Ãâó] http://stackoverflow.com/questions/4183708/how-to-get-the-formula-cell-valuedata-using-apache-poi


[Âü°í] http://stackoverflow.com/questions/6508203/when-getting-cell-content-using-apache-poi-library-i-get-both-cannot-get-a-num




Ãâó: http://bryan7.tistory.com/460 [¹Î¼­³×Áý]