bugzilla ticket 53642: added detailed logging for formula evaluation in both HSSF and XSSF modules

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1381249 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Evgeniy Berlog 2012-09-05 17:03:55 +00:00
parent e0db6f31a0
commit ddbbd7ba32
5 changed files with 23 additions and 11 deletions

View File

@ -319,16 +319,16 @@ for(int sheetNum = 0; sheetNum < wb.getNumberOfSheets(); sheetNum++) {
// activate logging to console // activate logging to console
System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger"); System.setProperty("org.apache.poi.util.POILogger", "org.apache.poi.util.SystemOutLogger");
System.setProperty("poi.log.level", POILogger.INFO + ""); System.setProperty("poi.log.level", POILogger.INFO + "");
// open your file // open your file
Workbook wb = new HSSFWorkbook(new FileInputStream("foobar.xls")); Workbook wb = new HSSFWorkbook(new FileInputStream("foobar.xls"));
HSSFFormulaEvaluator fe = (HSSFFormulaEvaluator) wb.getCreationHelper().createFormulaEvaluator(); FormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator();
// get your cell // get your cell
Cell cell = wb.getSheet(0).getRow(0).getCell(0); // just a dummy example Cell cell = wb.getSheet(0).getRow(0).getCell(0); // just a dummy example
// perform debug output for the next evaluate-call only // perform debug output for the next evaluate-call only
fe.setDebugEvaluationOutputForNextEval(true); evaluator.setDebugEvaluationOutputForNextEval(true);
evaluator.evaluateFormulaCell(cell); evaluator.evaluateFormulaCell(cell);
evaluator.evaluateFormulaCell(cell); // no logging performed for this next evaluate-call evaluator.evaluateFormulaCell(cell); // no logging performed for this next evaluate-call
</source> </source>

View File

@ -389,14 +389,7 @@ public class HSSFFormulaEvaluator implements FormulaEvaluator {
_bookEvaluator.setIgnoreMissingWorkbooks(ignore); _bookEvaluator.setIgnoreMissingWorkbooks(ignore);
} }
/** /** {@inheritDoc} */
* @param value whether perform detailed output
*
* Perform detailed output of formula evaluation for next evaluation only?
* Is for developer use only (also developers using POI for their XLS files).
* Log-Level WARN is for basic info, INFO for detailed information. These quite
* high levels are used because you have to explicitly enable this specific logging.
*/
public void setDebugEvaluationOutputForNextEval(boolean value){ public void setDebugEvaluationOutputForNextEval(boolean value){
_bookEvaluator.setDebugEvaluationOutputForNextEval(value); _bookEvaluator.setDebugEvaluationOutputForNextEval(value);
} }

View File

@ -114,4 +114,15 @@ public interface FormulaEvaluator {
* @param cell * @param cell
*/ */
Cell evaluateInCell(Cell cell); Cell evaluateInCell(Cell cell);
/**
* Perform detailed output of formula evaluation for next evaluation only?
* Is for developer use only (also developers using POI for their XLS files).
* Log-Level WARN is for basic info, INFO for detailed information. These quite
* high levels are used because you have to explicitly enable this specific logging.
* @param value whether to perform detailed output
*/
void setDebugEvaluationOutputForNextEval(boolean value);
} }

View File

@ -61,6 +61,8 @@ public class SheetUtil {
public void notifyUpdateCell(Cell cell) {} public void notifyUpdateCell(Cell cell) {}
public CellValue evaluate(Cell cell) {return null; } public CellValue evaluate(Cell cell) {return null; }
public Cell evaluateInCell(Cell cell) { return null; } public Cell evaluateInCell(Cell cell) { return null; }
public void setDebugEvaluationOutputForNextEval(boolean value) {}
public void evaluateAll() {} public void evaluateAll() {}
public int evaluateFormulaCell(Cell cell) { public int evaluateFormulaCell(Cell cell) {

View File

@ -279,4 +279,10 @@ public class XSSFFormulaEvaluator implements FormulaEvaluator {
} }
throw new RuntimeException("Unexpected eval class (" + eval.getClass().getName() + ")"); throw new RuntimeException("Unexpected eval class (" + eval.getClass().getName() + ")");
} }
/** {@inheritDoc} */
public void setDebugEvaluationOutputForNextEval(boolean value){
_bookEvaluator.setDebugEvaluationOutputForNextEval(value);
}
} }