There are other options but it does depend on what you wish to do. Take a look at the FormulaEvalutor interface - http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/FormulaEvaluator.html and the folowing page on the website - http://poi.apache.org/spreadsheet/eval.html - they will show you how to evaluate either single cells or whole workbooks. As far as I am aware, the setForceFormulaRecalculation() method simply indicates to Excel that formulae should be recalculated when a user opens the workbook using that application.
Yours Mark B saravanan6 wrote: > > Hi Hannes Erven > > > Thanks for your reply.... > > i found we can force the entire formula recaluation using below > line....... Please try it... > > mySheet.setForceFormulaRecalculation(true); > > > > > Hannes Erven-2 wrote: >> >> Hi, >> >> >>> (1) Here, i faced one problem like,,, my cell contains formula like >>> sum(a11:a20); >>> >>> suppose i modified the cell within the above range like a15 with new >>> value, >>> then my formula cell does not refelect new sum of the above specified >>> range. >> >> You probaly need to re-calculate the formulas. There is a keyboard >> shortcut in excel to force calculation, but you can also use POI to >> update all formulas. >> >> I use this code in one of my projects to accomplish this: >> >> public static void updateFormulas(Workbook wb) { >> int numSheets = wb.getNumberOfSheets(); >> for (int i = 0; i < numSheets; i++) { >> Sheet sheet = wb.getSheetAt(i); >> updateFormulas(sheet, wb); >> } >> } >> >> public static void updateFormulas(Sheet sheet, Workbook wb) { >> >> int firstrow = sheet.getFirstRowNum(); >> >> int lastrow = sheet.getLastRowNum(); >> >> for (int i = firstrow; i <= lastrow; i++) { >> >> Row row = sheet.getRow(i); >> if (row == null) { >> continue; >> } >> >> short firstcell = row.getFirstCellNum(); >> short lastcell = row.getLastCellNum(); >> >> for (int j = firstcell; j <= lastcell; j++) { >> Cell cell = row.getCell(j); >> >> if (cell != null && cell.getCellType() == >> Cell.CELL_TYPE_FORMULA) { >> String formel = cell.getCellFormula(); >> cell.setCellFormula(formel); >> } >> } >> } >> } >> >> >> >> -hannes >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: user-unsubscr...@poi.apache.org >> For additional commands, e-mail: user-h...@poi.apache.org >> >> >> > > -- View this message in context: http://old.nabble.com/APACHE-POI-WITH-JAVA-tp29062853p29069546.html Sent from the POI - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe, e-mail: user-unsubscr...@poi.apache.org For additional commands, e-mail: user-h...@poi.apache.org