From 20dfe361ca2933199deb65a6570b40740f86125b Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Tue, 1 Feb 2022 10:36:34 +0000 Subject: add excel Workbook.usesR1C1CellReferences() git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897649 13f79535-47bb-0310-9956-ffa450edef68 --- .../java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java | 6 +++++- .../java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java | 14 ++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) (limited to 'poi-ooxml') diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java index 189787f96b..584a1f3f23 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java @@ -1350,9 +1350,13 @@ public class SXSSFWorkbook implements Workbook { return _wb.addOlePackage(oleData, label, fileName, command); } - @Override public EvaluationWorkbook createEvaluationWorkbook() { return SXSSFEvaluationWorkbook.create(this); } + + @Override + public Boolean usesR1C1CellReferences() { + return getXSSFWorkbook().usesR1C1CellReferences(); + } } diff --git a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java index 7988e4e6e0..47e19e2956 100644 --- a/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -20,6 +20,7 @@ package org.apache.poi.xssf.usermodel; import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS; import static org.apache.poi.xssf.usermodel.helpers.XSSFPasswordHelper.setPassword; import static org.apache.poi.xssf.usermodel.helpers.XSSFPasswordHelper.validatePassword; +import static org.openxmlformats.schemas.spreadsheetml.x2006.main.STRefMode.*; import java.io.File; import java.io.IOException; @@ -1566,6 +1567,19 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su setPrintArea(sheetIndex, reference); } + @Override + public Boolean usesR1C1CellReferences() { + final CTCalcPr calcPr = getCTWorkbook().getCalcPr(); + if (calcPr == null) { + return null; + } else if (calcPr.getRefMode() == R_1_C_1) { + return Boolean.TRUE; + } else if (calcPr.getRefMode() == A_1) { + return Boolean.FALSE; + } + return null; + } + private static String getReferencePrintArea(String sheetName, int startC, int endC, int startR, int endR) { //windows excel example: Sheet1!$C$3:$E$4 CellReference colRef = new CellReference(sheetName, startR, startC, true, true); -- cgit v1.2.3