Bug 61863: Update JavaDoc to describe relation to workbook-level flag

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1875804 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Dominik Stadler 2020-03-28 09:49:24 +00:00
parent da2afc19e2
commit e88fac30b8
3 changed files with 111 additions and 62 deletions

View File

@ -398,6 +398,11 @@ public interface Sheet extends Iterable<Row> {
/** /**
* Whether Excel will be asked to recalculate all formulas in this sheet when the * Whether Excel will be asked to recalculate all formulas in this sheet when the
* workbook is opened. * workbook is opened.
*
* Note: This just returns if the sheet has the recalculate flag set and
* will still return false even if recalculation is enabled on workbook-level.
*
* @return true if the Sheet has the recalculate-flag set.
*/ */
boolean getForceFormulaRecalculation(); boolean getForceFormulaRecalculation();

View File

@ -2098,8 +2098,13 @@ public class XSSFSheet extends POIXMLDocumentPart implements Sheet {
} }
/** /**
* Whether Excel will be asked to recalculate all formulas when the * Whether Excel will be asked to recalculate all formulas of this sheet
* workbook is opened. * when the workbook is opened.
*
* Note: This just returns if the sheet has the recalculate flag set and
* will still return false even if recalculation is enabled on workbook-level.
*
* @return true if the Sheet has the recalculate-flag set.
*/ */
@Override @Override
public boolean getForceFormulaRecalculation() { public boolean getForceFormulaRecalculation() {

View File

@ -27,6 +27,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertSame; import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import java.io.FileInputStream;
import java.io.IOException; import java.io.IOException;
import java.util.Arrays; import java.util.Arrays;
import java.util.Calendar; import java.util.Calendar;
@ -36,6 +37,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import org.apache.poi.EncryptedDocumentException;
import org.apache.poi.hssf.HSSFTestDataSamples; import org.apache.poi.hssf.HSSFTestDataSamples;
import org.apache.poi.ooxml.POIXMLException; import org.apache.poi.ooxml.POIXMLException;
import org.apache.poi.poifs.crypt.CryptoFunctions; import org.apache.poi.poifs.crypt.CryptoFunctions;
@ -55,6 +57,7 @@ import org.apache.poi.ss.usermodel.IndexedColors;
import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.util.*; import org.apache.poi.ss.util.*;
import org.apache.poi.util.LocaleUtil; import org.apache.poi.util.LocaleUtil;
import org.apache.poi.xssf.XSSFITestDataProvider; import org.apache.poi.xssf.XSSFITestDataProvider;
@ -2002,4 +2005,40 @@ public final class TestXSSFSheet extends BaseTestXSheet {
assertNotNull(hfProp); assertNotNull(hfProp);
} }
} }
@Test
public void testSheetForceFormulaRecalculationDefaultValues() throws IOException {
try (Workbook wb = _testDataProvider.openSampleWorkbook("sample.xlsx")){
for (Sheet s : wb) {
assertEquals(wb.getForceFormulaRecalculation(),s.getForceFormulaRecalculation());
}
}
}
@Test
public void testWorkbookSetForceFormulaRecalculation() throws IOException {
try (Workbook wb = _testDataProvider.openSampleWorkbook("sample.xlsx")){
wb.setForceFormulaRecalculation(true);
assertTrue(wb.getForceFormulaRecalculation());
}
}
@Test
public void testNotCascadeWorkbookSetForceFormulaRecalculation() throws IOException {
try (Workbook wb = _testDataProvider.openSampleWorkbook("sample.xlsx")) {
// set all sheets to force recalculation
for (Sheet s : wb) {
s.setForceFormulaRecalculation(true);
assertTrue(s.getForceFormulaRecalculation());
}
// disable on workbook-level
wb.setForceFormulaRecalculation(false);
// on sheet-level, the flag is still set
for (Sheet s : wb) {
assertTrue("Sheet-level flag is still set to true", s.getForceFormulaRecalculation());
}
}
}
} }