aboutsummaryrefslogtreecommitdiffstats
path: root/src/ooxml/java
diff options
context:
space:
mode:
authorYegor Kozlov <yegor@apache.org>2009-04-17 18:02:01 +0000
committerYegor Kozlov <yegor@apache.org>2009-04-17 18:02:01 +0000
commit9eff4e10b36d171ed5a33771066b779604897aff (patch)
tree33621cb83b0e84d70138f56fbb3ee5b4cbebd138 /src/ooxml/java
parent2ab0a58566226570ecbf55b7700cfb31d1e60a74 (diff)
downloadpoi-9eff4e10b36d171ed5a33771066b779604897aff.tar.gz
poi-9eff4e10b36d171ed5a33771066b779604897aff.zip
Fixed XSSFCell to preserve cell style when cell value is set to blank, also avoid NPE in XSSFCell.setCellType() when workbook does not have SST, see bugs 47026 and 47028
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@766103 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/ooxml/java')
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java1
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java10
2 files changed, 6 insertions, 5 deletions
diff --git a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
index f0ad410adf..2a0e1ff4b2 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFCell.java
@@ -627,6 +627,7 @@ public final class XSSFCell implements Cell {
private void setBlank(){
CTCell blank = CTCell.Factory.newInstance();
blank.setR(cell.getR());
+ blank.setS(cell.getS());
cell.set(blank);
}
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 9cb66c5311..1648ac86f3 100644
--- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
+++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java
@@ -179,6 +179,11 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
}
}
+ if(sharedStringSource == null) {
+ //Create SST if it is missing
+ sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, XSSFFactory.getInstance());
+ }
+
// Load individual sheets. The order of sheets is defined by the order of CTSheet elements in the workbook
sheets = new ArrayList<XSSFSheet>(shIdMap.size());
for (CTSheet ctSheet : this.workbook.getSheets().getSheetArray()) {
@@ -192,11 +197,6 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
sheets.add(sh);
}
- if(sharedStringSource == null) {
- //Create SST if it is missing
- sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, XSSFFactory.getInstance());
- }
-
// Process the named ranges
namedRanges = new ArrayList<XSSFName>();
if(workbook.isSetDefinedNames()) {