public class TempFileSharedStringsTable
extends org.apache.poi.xssf.model.SharedStringsTable
A workbook may contain thousands of cells containing string (non-numeric) data. Furthermore this data is very likely to be repeated across many rows or columns. The goal of implementing a single string table that is shared across the workbook is to improve performance in opening and saving the file by only reading and writing the repetitive information once.
Consider for example a workbook summarizing information for cities within various countries. There may be a column for the name of the country, a column for the name of each city in that country, and a column containing the data for each city. In this case the country name is repetitive, being duplicated in many cells. In many cases the repetition is extensive, and a tremendous savings is realized by making use of a shared string table when saving the workbook. When displaying text in the spreadsheet, the cell table will just contain an index into the string table as the value of a cell, instead of the full string.
The shared string table contains all the necessary information for displaying the string: the text, formatting properties, and phonetic properties (for East Asian languages).
| Constructor and Description |
|---|
TempFileSharedStringsTable() |
TempFileSharedStringsTable(boolean encryptTempFiles) |
TempFileSharedStringsTable(boolean encryptTempFiles,
boolean fullFormat) |
TempFileSharedStringsTable(org.apache.poi.openxml4j.opc.OPCPackage pkg,
boolean encryptTempFiles) |
TempFileSharedStringsTable(org.apache.poi.openxml4j.opc.OPCPackage pkg,
boolean encryptTempFiles,
boolean fullFormat) |
| Modifier and Type | Method and Description |
|---|---|
int |
addSharedStringItem(org.apache.poi.ss.usermodel.RichTextString string)
Add an entry to this Shared String table (a new value is appended to the end).
|
void |
close() |
int |
getCount()
Return an integer representing the total count of strings in the workbook.
|
org.apache.poi.ss.usermodel.RichTextString |
getItemAt(int idx)
Return a string item by index
|
java.util.List<org.apache.poi.ss.usermodel.RichTextString> |
getSharedStringItems()
TempFileSharedStringsTable only supports streaming access of shared strings.
|
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 |
writeTo(java.io.OutputStream out)
Write this table out as XML.
|
_invokeOnDocumentRead, addRelation, createRelationship, createRelationship, createRelationship, getNextPartNumber, getPackagePart, getParent, getRelationById, getRelationId, getRelationPartById, getRelationParts, getRelations, getTargetPart, isCommitted, onDocumentCreate, onDocumentRead, onDocumentRemove, onSave, prepareForCommit, read, rebase, removeRelation, removeRelation, removeRelation, setCommitted, toStringpublic TempFileSharedStringsTable()
public TempFileSharedStringsTable(boolean encryptTempFiles)
public TempFileSharedStringsTable(boolean encryptTempFiles,
boolean fullFormat)
public TempFileSharedStringsTable(org.apache.poi.openxml4j.opc.OPCPackage pkg,
boolean encryptTempFiles)
throws java.io.IOException
java.io.IOExceptionpublic TempFileSharedStringsTable(org.apache.poi.openxml4j.opc.OPCPackage pkg,
boolean encryptTempFiles,
boolean fullFormat)
throws java.io.IOException
java.io.IOExceptionpublic void readFrom(java.io.InputStream is)
throws java.io.IOException
readFrom in class org.apache.poi.xssf.model.SharedStringsTableis - The input stream containing the XML document.java.io.IOException - if an error occurs while reading.public org.apache.poi.ss.usermodel.RichTextString getItemAt(int idx)
getItemAt in interface org.apache.poi.xssf.model.SharedStringsgetItemAt in class org.apache.poi.xssf.model.SharedStringsTableidx - index of item to return.java.util.NoSuchElementException - if no item exists for this indexpublic int getCount()
getCount in interface org.apache.poi.xssf.model.SharedStringsgetCount in class org.apache.poi.xssf.model.SharedStringsTablepublic int getUniqueCount()
getUniqueCount in interface org.apache.poi.xssf.model.SharedStringsgetUniqueCount in class org.apache.poi.xssf.model.SharedStringsTablepublic int addSharedStringItem(org.apache.poi.ss.usermodel.RichTextString string)
If the Shared String table already contains this string entry, its index is returned. Otherwise a new entry is added.
addSharedStringItem in class org.apache.poi.xssf.model.SharedStringsTablestring - the entry to addpublic java.util.List<org.apache.poi.ss.usermodel.RichTextString> getSharedStringItems()
getItemAt insteadgetSharedStringItems in class org.apache.poi.xssf.model.SharedStringsTablepublic void writeTo(java.io.OutputStream out)
throws java.io.IOException
writeTo in class org.apache.poi.xssf.model.SharedStringsTableout - The stream to write to.java.io.IOException - if an error occurs while writing.public void close()
throws java.io.IOException
close in interface java.io.Closeableclose in interface java.lang.AutoCloseableclose in class org.apache.poi.xssf.model.SharedStringsTablejava.io.IOException