use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSst in project poi by apache.
the class SharedStringsTable method readFrom.
/**
* Read this shared strings table from an XML file.
*
* @param is The input stream containing the XML document.
* @throws IOException if an error occurs while reading.
*/
public void readFrom(InputStream is) throws IOException {
try {
int cnt = 0;
_sstDoc = SstDocument.Factory.parse(is, DEFAULT_XML_OPTIONS);
CTSst sst = _sstDoc.getSst();
count = (int) sst.getCount();
uniqueCount = (int) sst.getUniqueCount();
for (CTRst st : sst.getSiArray()) {
stmap.put(getKey(st), cnt);
strings.add(st);
cnt++;
}
} catch (XmlException e) {
throw new IOException("unable to parse shared strings table", e);
}
}
use of org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSst in project poi by apache.
the class SharedStringsTable method writeTo.
/**
* Write this table out as XML.
*
* @param out The stream to write to.
* @throws IOException if an error occurs while writing.
*/
public void writeTo(OutputStream out) throws IOException {
XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
// the following two lines turn off writing CDATA
// see Bugzilla 48936
xmlOptions.setSaveCDataLengthThreshold(1000000);
xmlOptions.setSaveCDataEntityCountThreshold(-1);
//re-create the sst table every time saving a workbook
CTSst sst = _sstDoc.getSst();
sst.setCount(count);
sst.setUniqueCount(uniqueCount);
_sstDoc.save(out, xmlOptions);
}
Aggregations