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;
private List<XSSFSheet> sheets = new LinkedList<XSSFSheet>();
private SharedStringSource sharedStringSource;
+
+ private static POILogger log = POILogFactory.getLogger(XSSFWorkbook.class);
public XSSFWorkbook() {
this.workbook = CTWorkbook.Factory.newInstance();
// 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);
--- /dev/null
+# 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
import junit.framework.TestCase;
import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
protected void setUp() throws Exception {
super.setUp();
+ System.setProperty("org.apache.poi.util.POILogger", org.apache.poi.util.CommonsLogger.class.getName());
filename = System.getProperty("HSSF.testdata.path");
if (filename == null) {
- filename = "src/testcases/org/apache/poi/hssf/data";
+ filename = "src/ooxml/testcases/org/apache/poi/xssf/data";
}
}
cell = row.getCell((short) 0);
assertEquals("Lorem", cell.getRichStringCellValue().getString());
}
+
+ public void testLoadStyles() throws Exception {
+ XSSFWorkbook workbook = new XSSFWorkbook(new File(filename, "styles.xlsx").getAbsolutePath());
+ Sheet sheet = workbook.getSheetAt(0);
+ Row row = sheet.getRow(0);
+ Cell cell = row.getCell((short) 0);
+ CellStyle style = cell.getCellStyle();
+ // assertNotNull(style);
+ }
}