mirror of https://github.com/apache/poi.git
Fix bug #56278 - Support loading .xlsx files with no Styles Table
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1578518 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
b8c8567bc8
commit
b63080e7c4
|
@ -295,10 +295,15 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Iterable<X
|
||||||
shIdMap.put(p.getPackageRelationship().getId(), (XSSFSheet)p);
|
shIdMap.put(p.getPackageRelationship().getId(), (XSSFSheet)p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stylesSource == null) {
|
||||||
|
// Create Styles if it is missing
|
||||||
|
stylesSource = (StylesTable)createRelationship(XSSFRelation.STYLES, XSSFFactory.getInstance());
|
||||||
|
}
|
||||||
stylesSource.setTheme(theme);
|
stylesSource.setTheme(theme);
|
||||||
|
|
||||||
if(sharedStringSource == null) {
|
if(sharedStringSource == null) {
|
||||||
//Create SST if it is missing
|
// Create SST if it is missing
|
||||||
sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, XSSFFactory.getInstance());
|
sharedStringSource = (SharedStringsTable)createRelationship(XSSFRelation.SHARED_STRINGS, XSSFFactory.getInstance());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1440,4 +1440,19 @@ public final class TestXSSFBugs extends BaseTestBugzillaIssues {
|
||||||
assertEquals("#@_#", c.getStringCellValue());
|
assertEquals("#@_#", c.getStringCellValue());
|
||||||
assertEquals("http://invalid.uri", c.getHyperlink().getAddress());
|
assertEquals("http://invalid.uri", c.getHyperlink().getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Was giving NullPointerException
|
||||||
|
* at org.apache.poi.xssf.usermodel.XSSFWorkbook.onDocumentRead
|
||||||
|
* due to a lack of Styles Table
|
||||||
|
*/
|
||||||
|
@Test
|
||||||
|
public void bug56278() throws Exception {
|
||||||
|
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56278.xlsx");
|
||||||
|
assertEquals(0, wb.getSheetIndex("Market Rates"));
|
||||||
|
|
||||||
|
// Save and re-check
|
||||||
|
Workbook nwb = XSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||||
|
assertEquals(0, nwb.getSheetIndex("Market Rates"));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Binary file not shown.
Loading…
Reference in New Issue