From 9930e7099fc1c08623f9ad0fb4020926a41f03ef Mon Sep 17 00:00:00 2001 From: Yegor Kozlov Date: Thu, 30 Jun 2011 15:54:04 +0000 Subject: [PATCH] added Workbook.getForceFormulaRecalculation as requested in Bug 51422 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1141585 13f79535-47bb-0310-9956-ffa450edef68 --- .../org/apache/poi/hssf/usermodel/HSSFWorkbook.java | 12 ++++++++++++ src/java/org/apache/poi/ss/usermodel/Sheet.java | 2 +- src/java/org/apache/poi/ss/usermodel/Workbook.java | 7 +++++++ .../org/apache/poi/xssf/streaming/SXSSFWorkbook.java | 7 +++++++ .../org/apache/poi/xssf/usermodel/XSSFWorkbook.java | 12 ++++++++++++ .../apache/poi/xssf/usermodel/TestXSSFWorkbook.java | 4 ++++ .../org/apache/poi/hssf/model/TestWorkbook.java | 4 ++++ 7 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java index 6b3348aa4..178bb37a4 100644 --- a/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java +++ b/src/java/org/apache/poi/hssf/usermodel/HSSFWorkbook.java @@ -1792,4 +1792,16 @@ public final class HSSFWorkbook extends POIDocument implements org.apache.poi.ss recalc.setEngineId(0); } + /** + * Whether Excel will be asked to recalculate all formulas when the workbook is opened. + * + * @since 3.8 + */ + public boolean getForceFormulaRecalculation(){ + InternalWorkbook iwb = getWorkbook(); + RecalcIdRecord recalc = (RecalcIdRecord)iwb.findFirstRecordBySid(RecalcIdRecord.sid); + return recalc != null && recalc.getEngineId() != 0; + } + + } diff --git a/src/java/org/apache/poi/ss/usermodel/Sheet.java b/src/java/org/apache/poi/ss/usermodel/Sheet.java index bb4810f50..b7c145c26 100644 --- a/src/java/org/apache/poi/ss/usermodel/Sheet.java +++ b/src/java/org/apache/poi/ss/usermodel/Sheet.java @@ -319,7 +319,7 @@ public interface Sheet extends Iterable { void setForceFormulaRecalculation(boolean value); /** - * Whether Excel will be asked to recalculate all formulas when the + * Whether Excel will be asked to recalculate all formulas in this sheet when the * workbook is opened. */ boolean getForceFormulaRecalculation(); diff --git a/src/java/org/apache/poi/ss/usermodel/Workbook.java b/src/java/org/apache/poi/ss/usermodel/Workbook.java index 6ca460168..3ee44fdc1 100644 --- a/src/java/org/apache/poi/ss/usermodel/Workbook.java +++ b/src/java/org/apache/poi/ss/usermodel/Workbook.java @@ -564,4 +564,11 @@ public interface Workbook { */ public void setForceFormulaRecalculation(boolean value); + /** + * Whether Excel will be asked to recalculate all formulas when the workbook is opened. + * + * @since 3.8 + */ + boolean getForceFormulaRecalculation(); + } diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java index 6ca1f51e6..6ba4137b5 100644 --- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java @@ -835,5 +835,12 @@ public class SXSSFWorkbook implements Workbook _wb.setForceFormulaRecalculation(value); } + /** + * Whether Excel will be asked to recalculate all formulas when the workbook is opened. + */ + public boolean getForceFormulaRecalculation(){ + return _wb.getForceFormulaRecalculation(); + } + //end of interface implementation } diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index 95cbe7359..d8689d87a 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -1596,4 +1596,16 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable