public class ReadOnlySharedStringsTable extends DefaultHandler
This is a lightweight way to process the Shared Strings table. Most of the text cells will reference something from in here.
Note that each SI entry can have multiple T elements, if the string is made up of bits with different formatting.
Example input:
<?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="2" uniqueCount="2"> <si> <r> <rPr> <b /> <sz val="11" /> <color theme="1" /> <rFont val="Calibri" /> <family val="2" /> <scheme val="minor" /> </rPr> <t>This:</t> </r> <r> <rPr> <sz val="11" /> <color theme="1" /> <rFont val="Calibri" /> <family val="2" /> <scheme val="minor" /> </rPr> <t xml:space="preserve">Causes Problems</t> </r> </si> <si> <t>This does not</t> </si> </sst>
Constructor and Description |
---|
ReadOnlySharedStringsTable(OPCPackage pkg) |
ReadOnlySharedStringsTable(PackagePart part,
PackageRelationship rel_ignored)
Like POIXMLDocumentPart constructor
|
Modifier and Type | Method and Description |
---|---|
void |
characters(char[] ch,
int start,
int length)
Captures characters only if a t(ext) element is open.
|
void |
endElement(String uri,
String localName,
String name) |
int |
getCount()
Return an integer representing the total count of strings in the workbook.
|
String |
getEntryAt(int idx)
Return the string at a given index.
|
List<String> |
getItems() |
int |
getUniqueCount()
Returns an integer representing the total count of unique strings in the Shared String Table.
|
void |
readFrom(InputStream is)
Read this shared strings table from an XML file.
|
void |
startElement(String uri,
String localName,
String name,
Attributes attributes) |
endDocument, endPrefixMapping, error, fatalError, ignorableWhitespace, notationDecl, processingInstruction, resolveEntity, setDocumentLocator, skippedEntity, startDocument, startPrefixMapping, unparsedEntityDecl, warning
public ReadOnlySharedStringsTable(OPCPackage pkg) throws IOException, SAXException
pkg
- IOException
SAXException
ParserConfigurationException
public ReadOnlySharedStringsTable(PackagePart part, PackageRelationship rel_ignored) throws IOException, SAXException
part
- rel_ignored
- IOException
SAXException
public void readFrom(InputStream is) throws IOException, SAXException
is
- The input stream containing the XML document.IOException
- if an error occurs while reading.SAXException
ParserConfigurationException
public int getCount()
public int getUniqueCount()
public String getEntryAt(int idx)
idx
- index of item to return.public void startElement(String uri, String localName, String name, Attributes attributes) throws SAXException
startElement
in interface ContentHandler
startElement
in class DefaultHandler
SAXException
public void endElement(String uri, String localName, String name) throws SAXException
endElement
in interface ContentHandler
endElement
in class DefaultHandler
SAXException
public void characters(char[] ch, int start, int length) throws SAXException
characters
in interface ContentHandler
characters
in class DefaultHandler
SAXException
Copyright © 2020. All rights reserved.