aboutsummaryrefslogtreecommitdiffstats
path: root/poi-ooxml
diff options
context:
space:
mode:
authorPJ Fanning <fanningpj@apache.org>2022-02-01 11:06:37 +0000
committerPJ Fanning <fanningpj@apache.org>2022-02-01 11:06:37 +0000
commitf5a0a843ac965a23bd8407ba9c97209a8e933cae (patch)
treea85d361e890751be2a8660d90c75ae30e909202e /poi-ooxml
parent20dfe361ca2933199deb65a6570b40740f86125b (diff)
downloadpoi-f5a0a843ac965a23bd8407ba9c97209a8e933cae.tar.gz
poi-f5a0a843ac965a23bd8407ba9c97209a8e933cae.zip
add excel Workbook.setUseR1C1CellReferences(boolean)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1897652 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'poi-ooxml')
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java5
-rw-r--r--poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java27
2 files changed, 14 insertions, 18 deletions
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 584a1f3f23..3c392cc63c 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
@@ -1359,4 +1359,9 @@ public class SXSSFWorkbook implements Workbook {
public Boolean usesR1C1CellReferences() {
return getXSSFWorkbook().usesR1C1CellReferences();
}
+
+ @Override
+ public void setUseR1C1CellReferences(boolean useR1C1CellReferences) {
+ getXSSFWorkbook().setUseR1C1CellReferences(useR1C1CellReferences);
+ }
}
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 47e19e2956..0fd6eb56a9 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
@@ -97,24 +97,7 @@ import org.apache.poi.xssf.usermodel.helpers.XSSFFormulaUtils;
import org.apache.xmlbeans.XmlException;
import org.apache.xmlbeans.XmlObject;
import org.apache.xmlbeans.XmlOptions;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookView;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTBookViews;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCalcPr;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDefinedName;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDefinedNames;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTDialogsheet;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTExternalReference;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotCache;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotCaches;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheet;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheets;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbook;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookPr;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorkbookProtection;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STCalcMode;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.STSheetState;
-import org.openxmlformats.schemas.spreadsheetml.x2006.main.WorkbookDocument;
+import org.openxmlformats.schemas.spreadsheetml.x2006.main.*;
/**
* High level representation of a SpreadsheetML workbook. This is the first object most users
@@ -1580,6 +1563,14 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
return null;
}
+ @Override
+ public void setUseR1C1CellReferences(boolean useR1C1CellReferences) {
+ CTCalcPr calcPr = getCTWorkbook().getCalcPr();
+ if (calcPr == null) calcPr = getCTWorkbook().addNewCalcPr();
+ STRefMode.Enum refMode = useR1C1CellReferences ? R_1_C_1 : A_1;
+ calcPr.setRefMode(refMode);
+ }
+
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);