HSSFXML xml = new HSSFXML(
HXFDocument.openPackage(sampleFile)
);
assertNotNull(xml._getSharedStringsTable());
SharedStringsTable sst = xml._getSharedStringsTable();
assertEquals(10, sst.size());
assertEquals("Lorem", sst.get(0));
for(int i=0; i<sst.size(); i++) {
assertEquals(sst.get(i), xml.getSharedString(i));
}
// Add a few more, then save and reload, checking
// changes have been kept
sst.add("Foo");
sst.add("Bar");
sst.set(0, "LoremLorem");
sst.write();
xml = new HSSFXML(xml.getPackage());
sst = xml._getSharedStringsTable();
assertEquals(12, sst.size());
assertEquals("LoremLorem", sst.get(0));
for(int i=0; i<sst.size(); i++) {
assertEquals(sst.get(i), xml.getSharedString(i));
}
}