From cb55055d8383b8e858728a3129abbd550da29bd2 Mon Sep 17 00:00:00 2001 From: Ugo Cei Date: Tue, 19 Feb 2008 12:56:51 +0000 Subject: [PATCH] Moved test data file to own package. Start writing some tests for parsing cell styles. git-svn-id: https://svn.apache.org/repos/asf/poi/branches/ooxml@629092 13f79535-47bb-0310-9956-ffa450edef68 --- .../poi/xssf/usermodel/XSSFWorkbook.java | 8 ++++++ src/ooxml/testcases/log4j.properties | 24 ++++++++++++++++++ .../apache/poi/xssf/{io => data}/sample.xlsx | Bin .../org/apache/poi/xssf/data/styles.xlsx | Bin 0 -> 6557 bytes .../apache/poi/xssf/io/TestLoadSaveXSSF.java | 13 +++++++++- 5 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 src/ooxml/testcases/log4j.properties rename src/ooxml/testcases/org/apache/poi/xssf/{io => data}/sample.xlsx (100%) create mode 100644 src/ooxml/testcases/org/apache/poi/xssf/data/styles.xlsx 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 309225b3a6..4d261a4b31 100644 --- a/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java +++ b/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFWorkbook.java @@ -34,6 +34,8 @@ import org.apache.poi.ss.usermodel.Palette; import org.apache.poi.ss.usermodel.SharedStringSource; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.util.POILogFactory; +import org.apache.poi.util.POILogger; import org.apache.poi.xssf.strings.SharedStringsTable; import org.apache.xmlbeans.XmlException; import org.apache.xmlbeans.XmlObject; @@ -69,6 +71,8 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook { private List sheets = new LinkedList(); private SharedStringSource sharedStringSource; + + private static POILogger log = POILogFactory.getLogger(XSSFWorkbook.class); public XSSFWorkbook() { this.workbook = CTWorkbook.Factory.newInstance(); @@ -94,6 +98,10 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook { // Load individual sheets for (CTSheet ctSheet : this.workbook.getSheets().getSheetArray()) { PackageRelationship rel = this.getCorePart().getRelationship(ctSheet.getId()); + if (rel == null) { + log.log(log.WARN, "No relationship found for sheet " + ctSheet.getId()); + continue; + } PackagePart part = getPart(rel); WorksheetDocument worksheetDoc = WorksheetDocument.Factory.parse(part.getInputStream()); XSSFSheet sheet = new XSSFSheet(ctSheet, worksheetDoc.getWorksheet(), this); diff --git a/src/ooxml/testcases/log4j.properties b/src/ooxml/testcases/log4j.properties new file mode 100644 index 0000000000..8479c8de26 --- /dev/null +++ b/src/ooxml/testcases/log4j.properties @@ -0,0 +1,24 @@ +# Licensed to the Apache Software Foundation (ASF) under one or more +# contributor license agreements. See the NOTICE file distributed with +# this work for additional information regarding copyright ownership. +# The ASF licenses this file to You under the Apache License, Version 2.0 +# (the "License"); you may not use this file except in compliance with +# the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +log4j.debug=false + +log4j.rootLogger=INFO,Stdout + +log4j.appender.Stdout=org.apache.log4j.ConsoleAppender +log4j.appender.Stdout.layout=org.apache.log4j.PatternLayout +log4j.appender.Stdout.layout.conversionPattern=%-5p - %-26.26c{1} - %m\n + +log4j.org.apache.poi=DEBUG \ No newline at end of file diff --git a/src/ooxml/testcases/org/apache/poi/xssf/io/sample.xlsx b/src/ooxml/testcases/org/apache/poi/xssf/data/sample.xlsx similarity index 100% rename from src/ooxml/testcases/org/apache/poi/xssf/io/sample.xlsx rename to src/ooxml/testcases/org/apache/poi/xssf/data/sample.xlsx diff --git a/src/ooxml/testcases/org/apache/poi/xssf/data/styles.xlsx b/src/ooxml/testcases/org/apache/poi/xssf/data/styles.xlsx new file mode 100644 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