public class ReadOnlySharedStringsTable extends org.xml.sax.helpers.DefaultHandler implements SharedStrings
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>
Modifier and Type | Field and Description |
---|---|
protected int |
count
An integer representing the total count of strings in the workbook.
|
protected boolean |
includePhoneticRuns |
protected int |
uniqueCount
An integer representing the total count of unique strings in the Shared String Table.
|
Constructor and Description |
---|
ReadOnlySharedStringsTable(OPCPackage pkg)
Calls {
ReadOnlySharedStringsTable(OPCPackage, boolean) } with
a value of true for including phonetic runs |
ReadOnlySharedStringsTable(OPCPackage pkg,
boolean includePhoneticRuns) |
ReadOnlySharedStringsTable(PackagePart part)
Like POIXMLDocumentPart constructor
Calls
ReadOnlySharedStringsTable(PackagePart, boolean) , with a
value of true to include phonetic runs. |
ReadOnlySharedStringsTable(PackagePart part,
boolean includePhoneticRuns)
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(java.lang.String uri,
java.lang.String localName,
java.lang.String name) |
int |
getCount()
Return an integer representing the total count of strings in the workbook.
|
java.lang.String |
getEntryAt(int idx)
Deprecated.
use
getItemAt instead |
RichTextString |
getItemAt(int idx)
Return a string item by index
|
java.util.List<java.lang.String> |
getItems()
Deprecated.
use
getItemAt instead |
int |
getUniqueCount()
Returns an integer representing the total count of unique strings in the Shared String Table.
|
void |
readFrom(java.io.InputStream is)
Read this shared strings table from an XML file.
|
void |
startElement(java.lang.String uri,
java.lang.String localName,
java.lang.String name,
org.xml.sax.Attributes attributes) |
protected final boolean includePhoneticRuns
protected int count
protected int uniqueCount
public ReadOnlySharedStringsTable(OPCPackage pkg) throws java.io.IOException, org.xml.sax.SAXException
ReadOnlySharedStringsTable(OPCPackage, boolean)
} with
a value of true
for including phonetic runspkg
- The OPCPackage
to use as basis for the shared-strings table.java.io.IOException
- If reading the data from the package fails.org.xml.sax.SAXException
- if parsing the XML data fails.public ReadOnlySharedStringsTable(OPCPackage pkg, boolean includePhoneticRuns) throws java.io.IOException, org.xml.sax.SAXException
pkg
- The OPCPackage
to use as basis for the shared-strings table.includePhoneticRuns
- whether or not to concatenate phoneticRuns onto the shared stringjava.io.IOException
- If reading the data from the package fails.org.xml.sax.SAXException
- if parsing the XML data fails.public ReadOnlySharedStringsTable(PackagePart part) throws java.io.IOException, org.xml.sax.SAXException
ReadOnlySharedStringsTable(PackagePart, boolean)
, with a
value of true
to include phonetic runs.java.io.IOException
org.xml.sax.SAXException
public ReadOnlySharedStringsTable(PackagePart part, boolean includePhoneticRuns) throws java.io.IOException, org.xml.sax.SAXException
java.io.IOException
org.xml.sax.SAXException
public void readFrom(java.io.InputStream is) throws java.io.IOException, org.xml.sax.SAXException
is
- The input stream containing the XML document.java.io.IOException
- if an error occurs while reading.org.xml.sax.SAXException
- if parsing the XML data fails.public int getCount()
getCount
in interface SharedStrings
public int getUniqueCount()
getUniqueCount
in interface SharedStrings
@Removal(version="4.2") @Deprecated public java.lang.String getEntryAt(int idx)
getItemAt
insteadidx
- index of item to return.@Removal(version="4.2") @Deprecated public java.util.List<java.lang.String> getItems()
getItemAt
insteadpublic RichTextString getItemAt(int idx)
SharedStrings
getItemAt
in interface SharedStrings
idx
- index of item to return.public void startElement(java.lang.String uri, java.lang.String localName, java.lang.String name, org.xml.sax.Attributes attributes) throws org.xml.sax.SAXException
startElement
in interface org.xml.sax.ContentHandler
startElement
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void endElement(java.lang.String uri, java.lang.String localName, java.lang.String name) throws org.xml.sax.SAXException
endElement
in interface org.xml.sax.ContentHandler
endElement
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
public void characters(char[] ch, int start, int length) throws org.xml.sax.SAXException
characters
in interface org.xml.sax.ContentHandler
characters
in class org.xml.sax.helpers.DefaultHandler
org.xml.sax.SAXException
Copyright 2018 The Apache Software Foundation or its licensors, as applicable.