× The internal search function is temporarily non-functional. The current search engine is no longer viable and we are researching alternatives.
As a stop gap measure, we are using Google's custom search engine service.
If you know of an easy to use, open source, search engine ... please contact support@midrange.com.



On 6/4/2013 3:04 PM, John Rusling wrote:
Buck,

I'm using it too, didn't see anything in there that did this particular thing.

I'm guessing that I need the below method, which returns an int value -

evaluateFormulaCell()
http://poi.apache.org/apidocs/org/apache/poi/hssf/usermodel/HSSFFormulaEvaluator.html#evaluateFormulaCell%28org.apache.poi.ss.usermodel.Cell%29

So, I'm trying to piece it together now.

Thanks,

John

I use Scott Klement's wrappers over POI/HSSF:
http://www.scottklement.com/poi/
--buck


OK, I missed that. You're on the right track. I set up the evaluator
when I've opened the sheet:

// open the right tab in the workbook
sheet = ss_getSheet(book: 'Page1_1');
if (sheet = *null);
Complain('No sheet in workbook!');
endif;
maxRow = getLastRowNum(sheet);

// be able to evaluate formulas
helper = SSWorkbook_getCreationHelper(book);
formulaEvaluator = creationHelper_createFormulaEvaluator(helper);
newCellValue = new_CellValue(0);

and then in the loop where I read the columns:

when type = CELL_TYPE_FORMULA;
// evaluate the formula
newCellValue = evaluate(formulaEvaluator: cell);
newType = CellValue_getCellType(newCellValue);
if newType = CELL_TYPE_NUMERIC;
tempFloat = CellValue_getNumberValue(newCellValue);
else;
// handle as error
endif;

Hope this helps. I basically copied one of Scott's examples, but any
errors are mine :-)
--buck

As an Amazon Associate we earn from qualifying purchases.

This thread ...

Replies:

Follow On AppleNews
Return to Archive home page | Return to MIDRANGE.COM home page

This mailing list archive is Copyright 1997-2024 by midrange.com and David Gibbs as a compilation work. Use of the archive is restricted to research of a business or technical nature. Any other uses are prohibited. Full details are available on our policy page. If you have questions about this, please contact [javascript protected email address].

Operating expenses for this site are earned using the Amazon Associate program and Google Adsense.