Decryptor implementation for Agile Encryption
Set decryption password
instead of a password, it's also possible to decrypt via certificate.
Warning: this code is experimental and hasn't been validated
@see Agile encryption with certificates
@param keyPair
@param x509
@return true, when the data can be successfully decrypted with the given private key
@throws GeneralSecurityException
2.3.4.15 Data Encryption (Agile Encryption)
The EncryptedPackage stream (1) MUST be encrypted in 4096-byte segments to facilitate nearly
random access while allowing CBC modes to be used in the encryption Process.
The Initialization vector for the encryption process MUST be obtained by using the zero-based
segment number as a blockKey and the binary form of the KeyData.saltValue as specified in
section 2.3.4.12. The block number MUST be represented as a 32-bit unsigned integer.
Data blocks MUST then be encrypted by using the Initialization vector and the intermediate key
obtained by decrypting the encryptedKeyValue from a KeyEncryptor Contained within the
KeyEncryptors sequence as specified in section 2.3.4.10. The data block MUST be pAdded to
the next integral multiple of the KeyData.blockSize value. Any pAdding bytes can be used. Note
that the StreamSize field of the EncryptedPackage field specifies the number of bytes of
unencrypted data as specified in section 2.3.4.4.
Used when Checking if a key is valid for a document
Generate an HMAC, as specified in [RFC2104], of the encrypted form of the data (message),
which the DataIntegrity element will verify by using the Salt generated in step 2 as the key.
Note that the entire EncryptedPackage stream (1), including the StreamSize field, MUST be
used as the message.
Encrypt the HMAC as in step 3 by using a blockKey byte array consisting of the following bytes:
0xa0, 0x67, 0x7f, 0x02, 0xb2, 0x2c, 0x84, and 0x33.
2.3.4.15 Data Encryption (Agile Encryption)
The EncryptedPackage stream (1) MUST be encrypted in 4096-byte segments to facilitate nearly
random access while allowing CBC modes to be used in the encryption Process.
The Initialization vector for the encryption process MUST be obtained by using the zero-based
segment number as a blockKey and the binary form of the KeyData.saltValue as specified in
section 2.3.4.12. The block number MUST be represented as a 32-bit unsigned integer.
Data blocks MUST then be encrypted by using the Initialization vector and the intermediate key
obtained by decrypting the encryptedKeyValue from a KeyEncryptor Contained within the
KeyEncryptors sequence as specified in section 2.3.4.10. The data block MUST be pAdded to
the next integral multiple of the KeyData.blockSize value. Any pAdding bytes can be used. Note
that the StreamSize field of the EncryptedPackage field specifies the number of bytes of
unencrypted data as specified in section 2.3.4.4.
Exception thrown in case there is something wrong with the incoming eID
certificate.
@author Frank Cornelis
Digest Information data transfer class.
Main constructor.
@param digestValue
@param hashAlgo
@param description
Exception thrown in case the incoming eID certificate is expired.
@author Frank Cornelis
Signature Facet implementation to create enveloped signatures.
@author Frank Cornelis
Signature Facet implementation that Adds ds:KeyInfo to the XML signature.
@author Frank Cornelis
Work-around for Office2010 to accept the XAdES-BES/EPES signature.
xades:UnsignedProperties/xades:UnsignedSignatureProperties needs to be
present.
@author Frank Cornelis
Office OpenXML Signature Facet implementation.
@author fcorneli
@see [MS-OFFCRYPTO]: Office Document Cryptography Structure
Office 2010 list of signed types (extensions).
JSR105 Signature Facet base class.
This method is being invoked by the XML signature service engine during
pre-sign phase. Via this method a signature facet implementation can add
signature facets to an XML signature.
@param document the signature document to be used for imports
@param references list of reference defInitions
@param objects objects to be signed/included in the signature document
@throws XMLSignatureException
This method is being invoked by the XML signature service engine during
the post-sign phase. Via this method a signature facet can extend the XML
signatures with for example key information.
@param document the signature document to be modified
@throws MarshalException
XAdES Signature Facet. Implements XAdES v1.4.1 which is compatible with XAdES
v1.3.2. The implemented XAdES format is XAdES-BES/EPES. It's up to another
part of the signature service to upgrade the XAdES-BES to a XAdES-X-L.
This implementation has been tested against an implementation that
participated multiple ETSI XAdES plugtests.
@author Frank Cornelis
@see XAdES
Adds a mime-type for the given ds:Reference (referred via its @URI). This
information is Added via the xades:DataObjectFormat element.
@param dsReferenceUri
@param mimetype
XAdES-X-L v1.4.1 signature facet. This signature facet implementation will
upgrade a given XAdES-BES/EPES signature to XAdES-X-L.
We don't inherit from XAdESSignatureFacet as we also want to be able to use
this facet out of the context of a signature creation. This signature facet
assumes that the signature is already XAdES-BES/EPES compliant.
This implementation has been tested against an implementation that
participated multiple ETSI XAdES plugtests.
@author Frank Cornelis
@see XAdESSignatureFacet
JSR105 URI dereferencer for Office Open XML documents.
Exception thrown in case the incoming eID certificate has been revoked.
@author Frank Cornelis
Container class for PKI revocation data.
@author Frank Cornelis
Default constructor.
Adds a CRL to this revocation data Set.
@param encodedCrl
Adds a CRL to this revocation data Set.
@param crl
Adds an OCSP response to this revocation data Set.
@param encodedOcsp
Gives back a list of all CRLs.
@return a list of all CRLs
Gives back a list of all OCSP responses.
@return a list of all OCSP response
Returns true
if this revocation data Set holds OCSP
responses.
@return true
if this revocation data Set holds OCSP
responses.
Returns true
if this revocation data Set holds CRLs.
@return true
if this revocation data Set holds CRLs.
Returns true
if this revocation data is not empty.
@return true
if this revocation data is not empty.
Interface for a service that retrieves revocation data about some given
certificate chain.
@author Frank Cornelis
Gives back the revocation data corresponding with the given certificate
chain.
@param certificateChain the certificate chain
@return the revocation data corresponding with the given certificate chain.
Interface for the signature policy service.
@author Frank Cornelis
Gives back the signature policy identifier URI.
@return the signature policy identifier URI.
Gives back the short description of the signature policy or
null
if a description is not available.
@return the description, or null
.
Gives back the download URL where the signature policy document can be
found. Can be null
in case such a download location does not
exist.
@return the download URL, or null
.
Gives back the signature policy document.
@return the bytes of the signature policy document.
Interface for a time-stamp service.
@author Frank Cornelis
Gives back the encoded time-stamp token for the given array of data
bytes. We assume that the time-stamp token itself Contains its full
certificate chain required for proper validation.
@param data
the data to be time-stamped.
@param revocationData
the optional Container that needs to be Filled up with the
revocation data used to validate the TSA certificate chain.
@return the DER encoded time-stamp token.
@throws Exception
in case something went wrong.
Interface for trust validator of a TSP.
@author Frank Cornelis
Validates the given certificate chain.
@param certificateChain
@param revocationData
the optional data Container that should be Filled with
revocation data that was used to validate the given
certificate chain.
@throws Exception
in case the certificate chain is invalid.
A TSP time-stamp service implementation.
@author Frank Cornelis
Maps the digest algorithm to corresponding OID value.
This class bundles the configuration options used for the existing
signature facets.
Apart of the thread local members (e.g. opc-package) most values will probably be constant, so
it might be configured centrally (e.g. by spring)
the optional signature policy service used for XAdES-EPES.
the time-stamp service used for XAdES-T and XAdES-X.
timestamp service provider URL
if not defined, it's the same as the main digest
the optional TSP request policy OID.
the optional revocation data service used for XAdES-C and XAdES-X-L.
When null
the signature will be limited to XAdES-T only.
if not defined, it's the same as the main digest
Work-around for Office 2010 IssuerName encoding.
The signature Id attribute value used to create the XML signature. A
null
value will trigger an automatically generated signature Id.
Gives back the human-readable description of what the citizen will be
signing. The default value is "Office OpenXML Document".
The process of signing includes the marshalling of xml structures.
This also includes the canonicalization. Currently this leads to problems
with certain namespaces, so this EventListener is used to interfere
with the marshalling Process.
Map of namespace uris to prefix
If a mapping is specified, the corresponding elements will be prefixed
Inits and Checks the config object.
If not Set previously, complex configuration properties also Get
Created/initialized via this Initialization call.
@param onlyValidation if true, only a subset of the properties
is Initialized, which are necessary for validation. If false,
also the other properties needed for signing are been taken care of
@param signatureFacet the signature facet is Appended to facet list
@return the list of facets, may be empty when the config object is not Initialized
@param signatureFacets the new list of facets
@return the main digest algorithm, defaults to sha-1
@param digestAlgo the main digest algorithm
@return the opc package to be used by this thread, stored as thread-local
@param opcPackage the opc package to be handled by this thread, stored as thread-local
@return the private key
@param key the private key
@return the certificate chain, index 0 is usually the certificate matching
the private key
@param signingCertificateChain the certificate chain, index 0 should be
the certificate matching the private key
@return the time at which the document is signed, also used for the timestamp service.
defaults to now
@param executionTime Sets the time at which the document ought to be signed
@return the service to be used for XAdES-EPES properties. There's no default implementation
@param signaturePolicyService the service to be used for XAdES-EPES properties
@return Gives back the human-readable description of what the citizen
will be signing. The default value is "Office OpenXML Document".
@param signatureDescription the human-readable description of
what the citizen will be signing.
@return the default canonicalization method, defaults to INCLUSIVE
@param canonicalizationMethod the default canonicalization method
@return The signature Id attribute value used to create the XML signature.
Defaults to "idPackageSignature"
@param packageSignatureId The signature Id attribute value used to create the XML signature.
A null
value will trigger an automatically generated signature Id.
@return the url of the timestamp provider (TSP)
@param tspUrl the url of the timestamp provider (TSP)
@return if true, uses timestamp-request/response mimetype,
if false, timestamp-query/reply mimetype
@param tspOldProtocol defines the timestamp-protocol mimetype
@see #isTspOldProtocol
@return the hash algorithm to be used for the timestamp entry.
Defaults to the hash algorithm of the main entry
@param tspDigestAlgo the algorithm to be used for the timestamp entry.
if null
, the hash algorithm of the main entry
@return the proxy url to be used for all communications.
Currently this affects the timestamp service
@param proxyUrl the proxy url to be used for all communications.
Currently this affects the timestamp service
@return the timestamp service. Defaults to {@link TSPTimeStampService}
@param tspService the timestamp service
@return the user id for the timestamp service - currently only basic authorization is supported
@param tspUser the user id for the timestamp service - currently only basic authorization is supported
@return the password for the timestamp service
@param tspPass the password for the timestamp service
@return the validator for the timestamp service (certificate)
@param tspValidator the validator for the timestamp service (certificate)
@return the optional revocation data service used for XAdES-C and XAdES-X-L.
When null
the signature will be limited to XAdES-T only.
@param revocationDataService the optional revocation data service used for XAdES-C and XAdES-X-L.
When null
the signature will be limited to XAdES-T only.
@return hash algorithm used for XAdES. Defaults to the {@link #getDigestAlgo()}
@param xadesDigestAlgo hash algorithm used for XAdES.
When null
, defaults to {@link #getDigestAlgo()}
@return the user agent used for http communication (e.g. to the TSP)
@param userAgent the user agent used for http communication (e.g. to the TSP)
@return the asn.1 object id for the tsp request policy.
Defaults to 1.3.6.1.4.1.13762.3
@param tspRequestPolicy the asn.1 object id for the tsp request policy.
@return true, if the whole certificate chain is included in the signature.
When false, only the signer cert will be included
@param includeEntireCertificateChain if true, include the whole certificate chain.
If false, only include the signer cert
@return if true, issuer serial number is included
@param includeIssuerSerial if true, issuer serial number is included
@return if true, the key value of the public key (certificate) is included
@param includeKeyValue if true, the key value of the public key (certificate) is included
@return the xades role element. If null
the claimed role element is omitted.
Defaults to null
@param xadesRole the xades role element. If null
the claimed role element is omitted.
@return the Id for the XAdES SignedProperties element.
Defaults to idSignedProperties
@param xadesSignatureId the Id for the XAdES SignedProperties element.
When null
defaults to idSignedProperties
@return when true, include the policy-implied block.
Defaults to true
@param xadesSignaturePolicyImplied when true, include the policy-implied block
Make sure the DN is encoded using the same order as present
within the certificate. This is an Office2010 work-around.
Should be reverted back.
XXX: not correct according to RFC 4514.
@return when true, the issuer DN is used instead of the issuer X500 principal
@param xadesIssuerNameNoReverseOrder when true, the issuer DN instead of the issuer X500 prinicpal is used
@return the map of namespace uri (key) to prefix (value)
@param namespacePrefixes the map of namespace uri (key) to prefix (value)
helper method for null/default value handling
@param value
@param defaultValue
@return if value is not null, return value otherwise defaultValue
Each digest method has its own IV (Initial vector)
@return the IV depending on the main digest method
@return the uri for the signature method, i.e. currently only rsa is
supported, so it's the rsa variant of the main digest
@return the uri for the main digest
@param digestAlgo the digest algo, currently only sha* and ripemd160 is supported
@return the uri for the given digest
@return the cannonicalization method for XAdES-XL signing.
Defaults to EXCLUSIVE
@see javax.xml.Crypto.dsig.CanonicalizationMethod
@param xadesCanonicalizationMethod the cannonicalization method for XAdES-XL signing
@see javax.xml.Crypto.dsig.CanonicalizationMethod
Returns the URI of the referenced data object.
@return the URI of the data object in RFC 2396 format (may be
null
if not specified)
Returns the type of data referenced by this URI.
@return the type (a URI) of the data object (may be null
if not specified)
Dereferences the specified URIReference
and returns the
dereferenced data.
@param uriReference the URIReference
@param context an XMLCryptoContext
that may
contain additional useful information for dereferencing the URI. This
implementation should dereference the specified
URIReference
against the context's baseURI
parameter, if specified.
@return the dereferenced data
@throws NullPointerException if uriReference
or
context
are null
@throws URIReferenceException if an exception occurs while
dereferencing the specified uriReference
This method is called whenever an event occurs of the type for which
the EventListener
interface was registered.
@param evt The Event
contains contextual information
about the event. It also contains the stopPropagation
and preventDefault
methods which are used in
determining the event's flow and default action.
This class is the default entry point for XML signatures and can be used for
validating an existing signed office document and signing a office document.
Validating a signed office document
OPCPackage pkg = OPCPackage.open(..., PackageAccess.READ);
SignatureConfig sic = new SignatureConfig();
sic.setOpcPackage(pkg);
SignatureInfo si = new SignatureInfo();
si.setSignatureConfig(sic);
boolean isValid = si.validate();
...
Signing an office document
// loading the keystore - pkcs12 is used here, but of course jks & co are also valid
// the keystore needs to contain a private key and it's certificate having a
// 'digitalSignature' key usage
char password[] = "test".toCharArray();
File file = new File("test.pfx");
KeyStore keystore = KeyStore.getInstance("PKCS12");
FileInputStream fis = new FileInputStream(file);
keystore.load(fis, password);
fis.close();
// extracting private key and certificate
String alias = "xyz"; // alias of the keystore entry
Key key = keystore.getKey(alias, password);
X509Certificate x509 = (X509Certificate)keystore.getCertificate(alias);
// filling the SignatureConfig entries (minimum fields, more options are available ...)
SignatureConfig signatureConfig = new SignatureConfig();
signatureConfig.setKey(keyPair.getPrivate());
signatureConfig.setSigningCertificateChain(Collections.singletonList(x509));
OPCPackage pkg = OPCPackage.open(..., PackageAccess.READ_WRITE);
signatureConfig.setOpcPackage(pkg);
// adding the signature document to the package
SignatureInfo si = new SignatureInfo();
si.setSignatureConfig(signatureConfig);
si.confirmSignature();
// optionally verify the generated signature
boolean b = si.verifySignature();
assert (b);
// write the changes back to disc
pkg.close();
Implementation notes:
Although there's a XML signature implementation in the Oracle JDKs 6 and higher,
compatibility with IBM JDKs is also in focus (... but maybe not thoroughly tested ...).
Therefore we are using the Apache Santuario libs (xmlsec) instead of the built-in classes,
as the compatibility seems to be provided there.
To use SignatureInfo and its sibling classes, you'll need to have the following libs
in the classpath:
- BouncyCastle bcpkix and bcprov (tested against 1.51)
- Apache Santuario "xmlsec" (tested against 2.0.1)
- and slf4j-api (tested against 1.7.7)
@return the package part Containing the signature
@return the signer certificate
@return the certificate chain of the signer
@return true, when the xml signature is valid, false otherwise
@throws EncryptedDocumentException if the signature can't be extracted or if its malformed
Constructor Initializes xml signature environment, if it hasn't been Initialized before
@return the signature config
@param signatureConfig the signature config, needs to be Set before a SignatureInfo object is used
@return true, if first signature part is valid
add the xml signature to the document
@throws XMLSignatureException
@throws MarshalException
Sign (encrypt) the digest with the private key.
Currently only rsa is supported.
@param digest the hashed input
@return the encrypted hash
@return a signature part for each signature document.
the parts can be validated independently.
Initialize the xml signing environment and the bouncycastle provider
Helper method for Adding informations before the signing.
Normally {@link #ConfirmSignature()} is sufficient to be used.
Helper method for Adding informations After the signing.
Normally {@link #ConfirmSignature()} is sufficient to be used.
Write XML signature into the OPC package
@param document the xml signature document
@throws MarshalException
Helper method for null lists, which are Converted to empty lists
@param other the reference to wrap, if null
@return if other is null, an empty lists is returned, otherwise other is returned
This listener class is used, to modify the to be digested xml document,
e.g. to register id attributes or Set prefixes for registered namespaces
Exception thrown in case the incoming eID certificate is not trusted.
@author Frank Cornelis
The OPC Package
The properties of the OPC namespace, opened as needed
Wrapper to open a namespace, returning an IOException
in the event of a problem.
Works around shortcomings in java's this() constructor calls
Retrieves all the PackageParts which are defined as
relationships of the base document with the
specified content type.
Checks that the supplied Stream (which MUST
support mark and reSet, or be a PushbackStream)
has a OOXML (zip) header at the start of it.
If your Stream does not support mark / reSet,
then wrap it in a PushBackStream, then be
sure to always use that, and not the original!
@param inp An Stream which supports either mark/reSet, or is a PushbackStream
Get the document properties. This gives you access to the
core ooxml properties, and the extended ooxml properties.
Get the document's embedded files.
Closes the underlying {@link OPCPackage} from which this
document was read, if there is one
Write out this document to an Outputstream.
Note - if the Document was opened from a {@link File} rather
than an {@link InputStream}, you must write out to
a different file, overwriting via an OutputStream isn't possible.
If {@code stream} is a {@link java.io.FileOutputStream} on a networked drive
or has a high cost/latency associated with each written byte,
consider wrapping the OutputStream in a {@link java.io.BufferedOutputStream}
to improve write performance.
@param stream - the java Stream you wish to write the file to
@exception IOException if anything can't be written.
Represents an entry of a OOXML namespace.
Each POIXMLDocumentPart keeps a reference to the underlying a {@link org.apache.poi.openxml4j.opc.PackagePart}.
@author Yegor Kozlov
The RelationPart is a cached relationship between the document, which contains the RelationPart,
and one of its referenced child document parts.
The child document parts may only belong to one parent, but it's often referenced by other
parents too, having varying {@link PackageRelationship#getId() relationship ids} pointing to it.
@return the cached relationship, which uniquely identifies this child document part within the parent
@return the child document part
Counter that provides the amount of incoming relations from other parts
to this part.
Construct POIXMLDocumentPart representing a "core document" namespace part.
Construct POIXMLDocumentPart representing a custom "core document" package part.
Creates new POIXMLDocumentPart - called by client code to create new parts from scratch.
@see #CreateRelationship(POIXMLRelation, POIXMLFactory, int, bool)
Creates an POIXMLDocumentPart representing the given package part and relationship.
Called by {@link #read(POIXMLFactory, java.util.Map)} when reading in an existing file.
@param part - The package part that holds xml data representing this sheet.
@see #read(POIXMLFactory, java.util.Map)
@since POI 3.14-Beta1
Creates an POIXMLDocumentPart representing the given package part, relationship and parent
Called by {@link #read(POIXMLFactory, java.util.Map)} when reading in an existing file.
@param parent - Parent part
@param part - The package part that holds xml data representing this sheet.
@see #read(POIXMLFactory, java.util.Map)
@since POI 3.14-Beta1
Creates an POIXMLDocumentPart representing the given namespace part and relationship.
Called by {@link #read(POIXMLFactory, java.util.Map)} when Reading in an exisiting file.
@param part - The namespace part that holds xml data represenring this sheet.
@param rel - the relationship of the given namespace part
@see #read(POIXMLFactory, java.util.Map)
Creates an POIXMLDocumentPart representing the given namespace part, relationship and parent
Called by {@link #read(POIXMLFactory, java.util.Map)} when Reading in an exisiting file.
@param parent - Parent part
@param part - The namespace part that holds xml data represenring this sheet.
@param rel - the relationship of the given namespace part
@see #read(POIXMLFactory, java.util.Map)
When you open something like a theme, call this to
re-base the XML Document onto the core child of the
current core document
Provides access to the underlying PackagePart
@return the underlying PackagePart
Provides access to the PackageRelationship that identifies this POIXMLDocumentPart
@return the PackageRelationship that identifies this POIXMLDocumentPart
Returns the list of child relations for this POIXMLDocumentPart
@return child relations
Returns the list of child relations for this POIXMLDocumentPart
@return child relations
Returns the target {@link POIXMLDocumentPart}, where a
{@link PackageRelationship} is set from the {@link PackagePart} of this
{@link POIXMLDocumentPart} to the {@link PackagePart} of the target
{@link POIXMLDocumentPart} with a {@link PackageRelationship#GetId()}
matching the given parameter value.
@param id
The relation id to look for
@return the target part of the relation, or null, if none exists
Returns the {@link PackageRelationship#GetId()} of the
{@link PackageRelationship}, that sources from the {@link PackagePart} of
this {@link POIXMLDocumentPart} to the {@link PackagePart} of the given
parameter value.
@param part
The {@link POIXMLDocumentPart} for which the according
relation-id shall be found.
@return The value of the {@link PackageRelationship#GetId()} or null, if
parts are not related.
Add a new child POIXMLDocumentPart
@param part the child to add
@deprecated in POI 3.14, scheduled for removal in POI 3.16
Add a new child POIXMLDocumentPart
@param relId the preferred relation id, when null the next free relation id will be used
@param relationshipType the package relationship type
@param part the child to add
@since 3.14-Beta1
Add a new child POIXMLDocumentPart
@param pr the relationship of the child
@param part the child to add
Check if the new part was already added before via PackagePart.addRelationship()
to find the relationship for
The existing relationship, or null if there isn't yet one
Remove the relation to the specified part in this namespace and remove the
part, if it is no longer needed.
Remove the relation to the specified part in this namespace and remove the
part, if it is no longer needed and flag is set to true.
@param part
The related part, to which the relation shall be Removed.
@param RemoveUnusedParts
true, if the part shall be Removed from the namespace if not
needed any longer.
Returns the parent POIXMLDocumentPart. All parts except root have not-null parent.
@return the parent POIXMLDocumentPart or null
for the root element.
Save the content in the underlying namespace part.
Default implementation is empty meaning that the namespace part is left unmodified.
Sub-classes should override and add logic to marshal the "model" into Ooxml4J.
For example, the code saving a generic XML entry may look as follows:
protected void commit() {
PackagePart part = GetPackagePart();
Stream out = part.GetStream();
XmlObject bean = GetXmlBean(); //the "model" which holds Changes in memory
bean.save(out, DEFAULT_XML_OPTIONS);
out.close();
}
Save Changes in the underlying OOXML namespace.
Recursively fires {@link #commit()} for each namespace part
@param alreadySaved context set Containing already visited nodes
Ensure that a memory based package part does not have lingering data from previous
commit() calls.
Note: This is overwritten for some objects, as *PictureData seem to store the actual content
in the part directly without keeping a copy like all others therefore we need to handle them differently.
Create a new child POIXMLDocumentPart
@param descriptor the part descriptor
@param factory the factory that will create an instance of the requested relation
@return the Created child POIXMLDocumentPart
Create a new child POIXMLDocumentPart
@param descriptor the part descriptor
@param factory the factory that will create an instance of the requested relation
@param idx part number
@param noRelation if true, then no relationship is Added.
@return the Created child POIXMLDocumentPart
Iterate through the underlying PackagePart and create child POIXMLFactory instances
using the specified factory
@param factory the factory object that Creates POIXMLFactory instances
@param context context map Containing already visited noted keyed by tarGetURI
Get the PackagePart that is the target of a relationship.
@param rel The relationship
@return The target part
@throws InvalidFormatException
Fired when a new namespace part is Created
Fired when a namespace part is read
Fired when a namespace part is about to be Removed from the namespace
Retrieves the core document part
@since POI 3.14-Beta1
Defines a factory API that enables sub-classes to create instances of POIXMLDocumentPart
@author Yegor Kozlov
Create a POIXMLDocumentPart from existing package part and relation. This method is called
from {@link POIXMLDocument#load(POIXMLFactory)} when parsing a document
@param parent parent part
@param rel the package part relationship
@param part the PackagePart representing the created instance
@return A new instance of a POIXMLDocumentPart.
@since by POI 3.14-Beta1
Need to delegate instantiation to sub class because of constructor visibility
@since POI 3.14-Beta1
returns the descriptor for the given relationship type
@return the descriptor or null if type is unknown
@since POI 3.14-Beta1
Create a POIXMLDocumentPart from existing package part and relation. This method is called
from {@link POIXMLDocument#load(POIXMLFactory)} when parsing a document
@param parent parent part
@param rel the package part relationship
@param part the PackagePart representing the created instance
@return A new instance of a POIXMLDocumentPart.
@deprecated in POI 3.14, scheduled for removal in POI 3.16
Create a new POIXMLDocumentPart using the supplied descriptor. This method is used when adding new parts
to a document, for example, when adding a sheet to a workbook, slide to a presentation, etc.
@param descriptor describes the object to create
@return A new instance of a POIXMLDocumentPart.
Retrieves the package relationship of the child part within the parent
@since POI 3.14-Beta1
The core document properties
Extended document properties
Custom document properties
Each custom property element Contains an fmtid attribute
with the same GUID value ({D5CDD505-2E9C-101B-9397-08002B2CF9AE}).
Add a new property
@param name the property name
@throws IllegalArgumentException if a property with this name already exists
Add a new string property
@throws IllegalArgumentException if a property with this name already exists
Add a new double property
@throws IllegalArgumentException if a property with this name already exists
Add a new integer property
@throws IllegalArgumentException if a property with this name already exists
Add a new bool property
@throws IllegalArgumentException if a property with this name already exists
Generate next id that uniquely relates a custom property
@return next property id starting with 2
Check if a property with this name already exists in the collection of custom properties
@param name the name to check
@return whether a property with the given name exists in the custom properties
Retrieve the custom property with this name, or null if none exists.
You will need to test the various isSetX methods to work out
what the type of the property is, before fetching the
appropriate value for it.
@param name the name of the property to fetch
Wrapper around the three different kinds of OOXML properties
and metadata a document can have (Core, Extended and Custom),
as well Thumbnails.
Returns the core document properties
Returns the extended document properties
Returns the custom document properties
Returns the {@link PackagePart} for the Document
Thumbnail, or null
if there isn't one
@return The Document Thumbnail part or null
Returns the name of the Document thumbnail, eg
thumbnail.jpeg
, or null
if there
isn't one.
@return The thumbnail filename, or null
Returns the Document thumbnail image data, or
null
if there isn't one.
@return The thumbnail data, or null
Sets the Thumbnail for the document, replacing any existing
one.
@param name The filename for the thumbnail image, eg thumbnail.jpg
@param imageData The inputstream to read the thumbnail image from
Commit Changes to the underlying OPC namespace
A {@link POITextExtractor} for returning the textual
content of the OOXML file properties, eg author
and title.
Creates a new POIXMLPropertiesTextExtractor for the
given open document.
Creates a new POIXMLPropertiesTextExtractor, for the
same file that another TextExtractor is already
working on.
Returns the core document properties, eg author
Returns the extended document properties, eg
application
Returns the custom document properties, if
there are any
Represents a descriptor of a OOXML relation.
@author Yegor Kozlov
Describes the content stored in a part.
The kind of connection between a source part and a target part in a namespace.
The path component of a pack URI.
Defines what object is used to construct instances of this relationship
Instantiates a POIXMLRelation.
@param type content type
@param rel relationship
@param defaultName default item name
@param cls defines what object is used to construct instances of this relationship
Instantiates a POIXMLRelation.
@param type content type
@param rel relationship
@param defaultName default item name
Return the content type. Content types define a media type, a subtype, and an
optional set of parameters, as defined in RFC 2616.
@return the content type
Return the relationship, the kind of connection between a source part and a target part in a namespace.
Relationships make the connections between parts directly discoverable without looking at the content
in the parts, and without altering the parts themselves.
@return the relationship
Return the default part name. Part names are used to refer to a part in the context of a
namespace, typically as part of a URI.
@return the default part name
Returns the filename for the nth one of these,
e.g. /xl/comments4.xml
Returns the index of the filename within the package for the given part.
e.g. 4 for /xl/comments4.xml
Return type of the obejct used to construct instances of this relationship
@return the class of the object used to construct instances of this relation
The POIXMLDocument that's open
Creates a new text extractor for the given document
Returns the core document properties
Returns the extended document properties
Returns the custom document properties
Returns opened document
Returns the opened OPCPackage that Contains the document
Returns an OOXML properties text extractor for the
document properties metadata, such as title and author.
是否输出列头
是否输出隐藏的列
是否输出隐藏的行
是否输出文本前的空格
是否输出行号
在跨列的单元格使用DIV标记
@return maximum 1-base index of column that were rendered, zero if none
Creates COLGROUP element with width specified for all columns. (Except
first if {@link #isOutputRowNumbers()}==true)
Creates a map (i.e. two-dimensional array) filled with ranges. Allow fast
retrieving {@link CellRangeAddress} of any cell, if cell is contained in
range.
@see #getMergedRange(CellRangeAddress[][], int, int)
See here for Xio explanation and details
@param mergedRanges
map of sheet merged ranges built with
{@link #buildMergedRangesMap(HSSFSheet)}
@return {@link CellRangeAddress} from map if cell with specified row and
column numbers contained in found range, null otherwise
Only Text and Formulas are imported. Pictures, Drawing, Styles etc. are all ignored.
Only Text, Comments and Formulas are imported. Pictures, Drawing, Styles etc. are all ignored.
Everything is imported - this is the same as NONE.
Factory for creating the appropriate kind of Workbook
(be it HSSFWorkbook or XSSFWorkbook), from the given input
Creates an HSSFWorkbook from the given POIFSFileSystem
Creates an HSSFWorkbook from the given NPOIFSFileSystem
Creates a Workbook from the given NPOIFSFileSystem, which may
be password protected
Creates an XSSFWorkbook from the given OOXML Package
Creates the appropriate HSSFWorkbook / XSSFWorkbook from
the given InputStream. The Stream is wraped inside a PushbackInputStream.
Input Stream of .xls or .xlsx file
IWorkbook depending on the input HSSFWorkbook or XSSFWorkbook is returned.
Creates the appropriate HSSFWorkbook / XSSFWorkbook from
the given File, which must exist and be readable.
Note that for Workbooks opened this way, it is not possible
to explicitly close the underlying File resource.
Creates the appropriate HSSFWorkbook / XSSFWorkbook from
the given InputStream. The Stream is wraped inside a PushbackInputStream.
Input Stream of .xls or .xlsx file
Customize the elements that are processed on the next import
IWorkbook depending on the input HSSFWorkbook or XSSFWorkbook is returned.
Creates a specific FormulaEvaluator for the given workbook.
Sets the import option when opening the next workbook.
Works only for XSSF. For HSSF workbooks this option is ignored.
Customize the elements that are processed on the next import
24.08.2009 @author Stefan Stern
List of segments of available identifiers
@param lowerbound the lower limit of the id-range to manage. Must be greater than or equal to {@link #MIN_ID}.
@param upperbound the upper limit of the id-range to manage. Must be less then or equal {@link #MAX_ID}.
@return a new identifier.
@throws InvalidOperationException if no more identifiers are available, then an Exception is raised.
@param id
the identifier to release. Must be greater than or equal to
{@link #lowerbound} and must be less than or equal to {@link #upperbound}
@return true, if the identifier was reserved and has been successfully
released, false, if the identifier was not reserved.
Provides handy methods to work with OOXML namespaces
@author Yegor Kozlov
Clone the specified namespace.
@param pkg the namespace to clone
@param file the destination file
@return the Cloned namespace
Creates an empty file in the default temporary-file directory,
Recursively copy namespace parts to the destination namespace
Copy core namespace properties
@param src source properties
@param tgt target properties
Helper class to extract text from an OOXML Excel file
Should header and footer be included? Default is true
Should sheet names be included? Default is true
if set to true [include sheet names].
Should we return the formula itself, and not
the result it produces? Default is false
if set to true [formulas not results].
Should cell comments be included? Default is false
if set to true [include cell comments].
Should sheet names be included? Default is true
Should we return the formula itself, and not
the result it produces? Default is false
Should cell comments be included? Default is false
Should headers and footers be included? Default is true
Should text within textboxes be included? Default is true
@param includeTextBoxes
Retreives the text contents of the file
Maps an XLSX to an XML according to one of the mapping defined.
The output XML Schema must respect this limitations:
- all mandatory elements and attributes must be mapped (enable validation to check this)
- no <any> in complex type/element declaration
- no <anyAttribute> attributes declaration
- no recursive structures: recursive structures can't be nested more than one level
- no abstract elements: abstract complex types can be declared but must not be used in elements.
- no mixed content: an element can't contain simple text and child element(s) together
- no <substitutionGroup> in complex type/element declaration
Creates a new exporter and Sets the mapping to be used when generating the XML output document
@param map the mapping rule to be used
Exports the data in an XML stream
@param os OutputStream in which will contain the output XML
@param validate if true, validates the XML againts the XML Schema
@throws SAXException
@throws TransformerException
@throws ParserConfigurationException
Exports the data in an XML stream
@param os OutputStream in which will contain the output XML
@param encoding the output charset encoding
@param validate if true, validates the XML againts the XML Schema
@throws SAXException
@throws ParserConfigurationException
@throws TransformerException
@throws InvalidFormatException
Validate the generated XML against the XML Schema associated with the XSSFMap
@param xml the XML to validate
@return
Compares two xpaths to define an ordering according to the XML Schema
The cells in a workbook can be calculated in different orders depending on various optimizations and
dependencies. The calculation chain object specifies the order in which the cells in a workbook were last calculated.
@author Yegor Kozlov
Remove a formula reference from the calculation chain
@param sheetId the sheet Id of a sheet the formula belongs to.
@param ref A1 style reference to the cell Containing the formula.
XML Beans uses a list, which is very slow
to search, so we wrap things with our own
map for fast Lookup.
Called after the reference is updated, so that
we can reflect that in our cache
Called after the reference is updated, so that
we can reflect that in our cache
@param oldReference the comment to remove from the commentRefs map
@param comment the comment to replace in the commentRefs map
Searches the author. If not found he is added to the list of authors.
author to search
index of the author
Finds the cell comment at cellAddress, if one exists
@param cellAddress the address of the cell to find a comment
@return cell comment if one exists, otherwise returns null
@
Finds the cell comment at cellAddress, if one exists
@param cellAddress the address of the cell to find a comment
@return cell comment if one exists, otherwise returns null
Get the underlying CTComment xmlbean for a comment located at cellRef, if it exists
@param cellRef the location of the cell comment
@return CTComment xmlbean if comment exists, otherwise return null.
@
Get the underlying CTComment xmlbean for a comment located at cellRef, if it exists
@param cellRef the location of the cell comment
@return CTComment xmlbean if comment exists, otherwise return null.
Returns all cell comments on this sheet.
@return A map of each Comment in this sheet, keyed on the cell address where
the comment is located.
Create a new comment located at cell address
@param ref the location to add the comment
@return a new CTComment located at ref with default author
Create a new comment located` at cell address
@param ref the location to add the comment
@return a new CTComment located at ref with default author
Remove the comment at cellRef location, if one exists
@param cellRef the location of the comment to remove
@return returns true if a comment was removed
@deprecated 2015-11-23 (circa POI 3.14beta1). Use {@link #removeComment(CellAddress)} instead
Remove the comment at cellRef location, if one exists
@param cellRef the location of the comment to remove
@return returns true if a comment was removed
Add a new author to the CommentsTable.
This does not check if the author already exists.
@param author the name of the comment author
@return the index of the new author
Returns the underlying CTComments list xmlbean
@return underlying comments list xmlbean
Holds details of links to parts of other workbooks (eg named ranges),
along with the most recently seen values for what they point to.
Returns the underlying xmlbeans object for the external
link table
get or set the last recorded name of the file that this
is linked to
This class : the Custom XML Mapping Part (Open Office XML Part 1:
chapter 12.3.6)
An instance of this part type Contains a schema for an XML file, and
information on the behavior that is used when allowing this custom XML schema
to be mapped into the spreadsheet.
@author Roberto Manicardi
Returns the parent XSSFWorkbook
@return the parent XSSFWorkbook
@return the internal data object
Gets the
@param schemaId the schema ID
@return CTSchema by it's ID
@return all the mappings configured in this document
Used internally to navigate the paragraph text style hierarchy within a shape and fetch properties
@param shape the shape being examined
@return true if the desired property was fetched
Table of strings shared across all sheets in a workbook.
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).
@author Nick Birch
@author Yegor Kozlov
Array of individual string items in the Shared String table.
Maps strings and their indexes in the strings
arrays
An integer representing the total count of strings in the workbook. This count does not
include any numbers, it counts only the total of text strings in the workbook.
An integer representing the total count of unique strings in the Shared String Table.
A string is unique even if it is a copy of another string, but has different formatting applied
at the character level.
Return a string item by index
@param idx index of item to return.
@return the item at the specified position in this Shared String table.
Return an integer representing the total count of strings in the workbook. This count does not
include any numbers, it counts only the total of text strings in the workbook.
@return the total count of strings in the workbook
Returns an integer representing the total count of unique strings in the Shared String Table.
A string is unique even if it is a copy of another string, but has different formatting applied
at the character level.
@return the total count of unique strings in the workbook
Add an entry to this Shared String table (a new value is appened to the end).
If the Shared String table already Contains this CT_Rst
bean, its index is returned.
Otherwise a new entry is aded.
@param st the entry to add
@return index the index of Added entry
Provide low-level access to the underlying array of CT_Rst beans
@return array of CT_Rst beans
this table out as XML.
@param out The stream to write to.
@throws IOException if an error occurs while writing.
This class : the Single Cell Tables Part (Open Office XML Part 4:
chapter 3.5.2)
@author Roberto Manicardi
@return all the SimpleXmlCell Contained in this SingleXmlCells element
Table of styles shared across all sheets in a workbook.
@author ugo
The first style id available for use as a custom style
Depending on the version of Excel, the maximum number of number formats in a workbook is between 200 and 250
See https://support.office.com/en-us/article/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
POI defaults this limit to 250, but can be increased or decreased on a per-StylesTable basis with
{@link #setMaxNumberOfDataFormats(int)} if needed.
Get the upper limit on the number of data formats that has been set for the style table.
To get the current number of data formats in use, use {@link #getNumDataFormats()}.
@return the maximum number of data formats allowed in the workbook
Create a new, empty StylesTable
If there isn't currently a {@link ThemesTable} for the
current Workbook, then creates one and sets it up.
After this, calls to {@link #getTheme()} won't give null
Read this shared styles table from an XML file.
@param is The input stream Containing the XML document.
@throws IOException if an error occurs while Reading.
Get number format string given its id
@param idx number format id
@return number format code
Get number format string given its id
@param fmtId number format id
@return number format code
Puts fmt
in the numberFormats map if the format is not
already in the the number format style table.
Does nothing if fmt
is already in number format style table.
@param fmt the number format to add to number format style table
@return the index of fmt
in the number format style table
Add a number format with a specific ID into the numberFormats map.
If a format with the same ID already exists, overwrite the format code
with fmt
This may be used to override built-in number formats.
@param index the number format ID
@param fmt the number format code
Remove a number format from the style table if it exists.
All cell styles with this number format will be modified to use the default number format.
@param fmt the number format to remove
@return true if the number format was removed
Remove a number format from the style table if it exists
All cell styles with this number format will be modified to use the default number format
@param fmt the number format to remove
@return true if the number format was removed
Records the given font in the font table.
Will re-use an existing font index if this
font matches another, EXCEPT if forced
registration is requested.
This allows people to create several fonts
then customise them later.
Note - End Users probably want to call
{@link XSSFFont#registerTo(StylesTable)}
Adds a border to the border style table if it isn't already in the style table
Does nothing if border is already in borders style table
border to add
return the index of the added border
Adds a fill to the fill style table if it isn't already in the style table
Does nothing if fill is already in fill style table
fill to add
return the index of the added fill
Adds a cell to the styles table. Does not check for duplicates
the cell to add to the styles table
return the added cell ID in the style table
Adds a cell style to the styles table.Does not check for duplicates.
the cell style to add to the styles table
return the cell style ID in the style table
get the size of cell styles
@return number of data formats in the styles table
For unit testing only
For unit testing only
For unit testing only
For unit testing only!
Write this table out as XML.
@param out The stream to write to.
@throws IOException if an error occurs while writing.
Adds a Dxf to the style table Does not check for duplicates.
the Dxf to add
added dxf ID in the style table
Create a cell style in this style table.
Note - End users probably want to call {@link XSSFWorkbook#createCellStyle()}
rather than working with the styles table directly.
Finds a font that matches the one with the supplied attributes
Finds a font that matches the one with the supplied attributes
Class that represents theme of XLSX document. The theme includes specific
colors and fonts.
Create a new, empty ThemesTable
Construct a ThemesTable.
@param part A PackagePart.
@param rel A PackageRelationship.
Construct a ThemesTable from an existing ThemeDocument.
@param theme A ThemeDocument.
Convert a theme "index" into a color.
@param idx A theme "index"
@return The mapped XSSFColor, or null if not mapped.
If the colour is based on a theme, then inherit
information (currently just colours) from it as
required.
Write this table out as XML.
@param out The stream to write to.
@throws IOException if an error occurs while writing.
map of tracked columns, with values containing the best-fit width for the column
Using a HashMap instead of a TreeMap because insertion (trackColumn), removal (untrackColumn), and membership (everything)
will be called more frequently than getTrackedColumns(). The O(1) cost of insertion, removal, and membership operations
outweigh the infrequent O(n*log n) cost of sorting getTrackedColumns().
Memory consumption for a HashMap and TreeMap is about the same
Gets the current best-fit column width for the provided settings
@param useMergedCells true if merged cells are considered into the best-fit column width calculation
@return best fit column width, measured in default character widths.
Sets the best-fit column width to the maximum of the current width and the provided width
@param unmergedWidth the best-fit column width calculated with useMergedCells=False
@param mergedWidth the best-fit column width calculated with useMergedCells=True
AutoSizeColumnTracker constructor. Holds no reference to sheet
@param sheet the sheet associated with this auto-size column tracker
@since 3.14beta1
Get the currently tracked columns, naturally ordered.
Note if all columns are tracked, this will only return the columns that have been explicitly or implicitly tracked,
which is probably only columns containing 1 or more non-blank values
@return a set of the indices of all tracked columns
@since 3.14beta1
Returns true if column is currently tracked for auto-sizing.
@param column the index of the column to check
@return true if column is tracked
@since 3.14beta1
Returns true if all columns are implicitly tracked.
@return true if all columns are implicitly tracked
@since 3.14beta1
Tracks all non-blank columns
Allows columns that have been explicitly untracked to be tracked
@since 3.14beta1
Untrack all columns that were previously tracked for auto-sizing.
All best-fit column widths are forgotten.
@since 3.14beta1
Marks multiple columns for inclusion in auto-size column tracking.
Note this has undefined behavior if columns are tracked after one or more rows are written to the sheet.
Any column in columns
that are already tracked are ignored by this call.
@param columns the indices of the columns to track
@since 3.14beta1
Marks a column for inclusion in auto-size column tracking.
Note this has undefined behavior if a column is tracked after one or more rows are written to the sheet.
If column
is already tracked, this call does nothing.
@param column the index of the column to track for auto-sizing
@return if column is already tracked, the call does nothing and returns false
@since 3.14beta1
Implicitly track a column if it has not been explicitly untracked
If it has been explicitly untracked, this call does nothing and returns false.
Otherwise return true
@param column the column to implicitly track
@return false if column has been explicitly untracked, otherwise return true
Removes columns that were previously marked for inclusion in auto-size column tracking.
When a column is untracked, the best-fit width is forgotten.
Any column in columns
that is not tracked will be ignored by this call.
@param columns the indices of the columns to track for auto-sizing
@return true if one or more columns were untracked as a result of this call
@since 3.14beta1
Removes a column that was previously marked for inclusion in auto-size column tracking.
When a column is untracked, the best-fit width is forgotten.
If column
is not tracked, it will be ignored by this call.
@param column the index of the column to track for auto-sizing
@return true if column was tracked prior this call, false if no action was taken
@since 3.14beta1
Get the best-fit width of a tracked column
@param column the index of the column to get the current best-fit width of
@param useMergedCells true if merged cells should be considered when computing the best-fit width
@return best-fit column width, measured in number of characters
@throws InvalidOperationException if column is not tracked and trackAllColumns is false
@since 3.14beta1
Calculate the best fit width for each tracked column in row
@param row the row to get the cells
@since 3.14beta1
Helper for {@link #updateColumnWidths(Row)}.
Implicitly track the columns corresponding to the cells in row.
If all columns in the row are already tracked, this call does nothing.
Explicitly untracked columns will not be tracked.
@param row the row containing cells to implicitly track the columns
@since 3.14beta1
Helper for {@link #updateColumnWidths(Row)}.
@param cell the cell to compute the best fit width on
@param pair the column width pair to update
@since 3.14beta1
@param sharedStringsTable the shared strings table, or null if inline text is used
@return temp file to write sheet data
Table of strings shared across this workbook.
If two cells contain the same string, then the cell value is the same index into SharedStringsTable
Create a temp file to write sheet data.
By default, temp files are created in the default temporary-file directory
with a prefix "poi-sxssf-sheet" and suffix ".xml". Subclasses can override
it and specify a different temp directory or filename or suffix, e.g. .gz
@return temp file to write sheet data
Create a writer for the sheet data.
@param fd the file to write to
Override this to translate (such as encrypt or compress) the file output stream
as it is being written to disk.
The default behavior is to to pass the stream through unmodified.
@param fos the stream to decorate
@return a decorated stream
@throws IOException
@see #decorateInputStream(FileInputStream)
flush and close the temp data writer.
This method must be invoked before calling {@link #getWorksheetXMLInputStream()}
@return a stream to read temp file with the sheet data
Override this to translate (such as decrypt or expand) the file input stream
as it is being read from disk.
The default behavior is to to pass the stream through unmodified.
@param fis the stream to decorate
@return a decorated stream
@throws IOException
@see #decorateOutputStream(FileOutputStream)
Write a row to the file
@param rownum 0-based row number
@param row a row
@return whether the string has leading / trailing spaces that
need to be preserved with the xml:space=\"preserve\" attribute
Deletes the temporary file that backed this sheet on disk.
@return true if the file was deleted, false if it wasn't.
Used to help format error messages
Will return {@link CellType} in a future version of POI.
For forwards compatibility, do not hard-code cell type literals in your code.
@return cell type
@since POI 3.15 beta 3
@deprecated POI 3.15 beta 3.
Will be deleted when we make the CellType enum transition. See bug 59791.
Will return {@link CellType} in a future version of POI.
For forwards compatibility, do not hard-code cell type literals in your code.
@return cell type of cached formula result
@since POI 3.15 beta 3
@deprecated POI 3.15 beta 3.
Will be deleted when we make the CellType enum transition. See bug 59791.
Loops over rows and cells, evaluating formula cells there.
If any sheets are inactive, or any cells outside of the window,
will give an Exception.
For SXSSF, you generally don't want to use this method, instead
evaluate your formulas as you go before they leave the window.
Compares two SXSSFRow
objects. Two rows are equal if they belong to the same worksheet and
their row indexes are equal.
@param other the SXSSFRow
to be compared.
@return
-
the value
0
if the row number of this SXSSFRow
is
equal to the row number of the argument SXSSFRow
-
a value less than
0
if the row number of this this SXSSFRow
is
numerically less than the row number of the argument SXSSFRow
-
a value greater than
0
if the row number of this this SXSSFRow
is
numerically greater than the row number of the argument SXSSFRow
@throws IllegalArgumentException if the argument row belongs to a different worksheet
throws RuntimeException if the bounds are exceeded.
Return the column number of a cell if it is in this row
Otherwise return -1
@param cell the cell to get the index of
@return cell column index if it is in this row, -1 otherwise
Create an iterator over the cells from [0, getLastCellNum()).
Includes blank cells, excludes empty cells
Returns an iterator over all filled cells (created via Row.createCell())
Throws ConcurrentModificationException if cells are added, moved, or
removed after the iterator is created.
Returns whether row and column headings are printed.
@return whether row and column headings are printed
Returns the list of merged regions. If you want multiple regions, this is
faster than calling {@link #getMergedRegion(int)} each time.
@return the list of merged regions
Adds a merged region of cells (hence those cells form one).
Skips validation.It is possible to create overlapping merged regions
or create a merged region that intersects a multi-cell array formula
with this formula, which may result in a corrupt workbook.
region to merge
index of this region
if region contains fewer than 2 cells
Verify that merged regions do not intersect multi-cell array formulas and
no merged regions intersect another merged region in this sheet.
@throws InvalidOperationException if region intersects with a multi-cell array formula
@throws InvalidOperationException if at least one region intersects with another merged region in this sheet
Adjusts the column width to fit the contents.
This process can be relatively slow on large sheets, so this should
normally only be called once per column, at the end of your
processing.
You can specify whether the content of merged cells should be considered or ignored.
Default is to ignore merged cells.
Special note about SXSSF implementation: You must register the columns you wish to track with
the SXSSFSheet using {@link #trackColumnForAutoSizing(int)} or {@link #trackAllColumnsForAutoSizing()}.
This is needed because the rows needed to compute the column width may have fallen outside the
random access window and been flushed to disk.
Tracking columns is required even if all rows are in the random access window.
New in POI 3.14 beta 1: auto-sizes columns using cells from current and flushed rows.
@param column the column index to auto-size
Adjusts the column width to fit the contents.
This process can be relatively slow on large sheets, so this should
normally only be called once per column, at the end of your
processing.
You can specify whether the content of merged cells should be considered or ignored.
Default is to ignore merged cells.
Special note about SXSSF implementation: You must register the columns you wish to track with
the SXSSFSheet using {@link #trackColumnForAutoSizing(int)} or {@link #trackAllColumnsForAutoSizing()}.
This is needed because the rows needed to compute the column width may have fallen outside the
random access window and been flushed to disk.
Tracking columns is required even if all rows are in the random access window.
New in POI 3.14 beta 1: auto-sizes columns using cells from current and flushed rows.
@param column the column index to auto-size
@param useMergedCells whether to use the contents of merged cells when calculating the width of the column
Get a Hyperlink in this sheet anchored at row, column
The index of the row of the hyperlink, zero-based
the index of the column of the hyperlink, zero-based
return hyperlink if there is a hyperlink anchored at row, column; otherwise returns null
Get a Hyperlink in this sheet located in a cell specified by {code addr}
The address of the cell containing the hyperlink
return hyperlink if there is a hyperlink anchored at {@code addr}; otherwise returns {@code null}
Get a list of Hyperlinks in this sheet
@return Hyperlinks for the sheet
Returns cell comment for the specified row and column
The row.
The column.
cell comment or null
if not found
Returns cell comment for the specified location
cell location
return cell comment or null if not found
Returns all cell comments on this sheet.
return A Dictionary of each Comment in the sheet, keyed on the cell address where the comment is located.
Set row groupings (like groupRow) in a stream-friendly manner
groupRows requires all rows in the group to be in the current window.
This is not always practical. Instead use setRowOutlineLevel to
explicitly set the group level. Level 1 is the top level group,
followed by 2, etc. It is up to the user to ensure that level 2
groups are correctly nested under level 1, etc.
@param rownum index of row to update (0-based)
@param level outline level (greater than 0)
Removes a merged region of cells (hence letting them free)
@param indices of the regions to unmerge
Track a column in the sheet for auto-sizing.
Note this has undefined behavior if a column is tracked after one or more rows are written to the sheet.
If column
is already tracked, this call does nothing.
@param column the column to track for autosizing
@since 3.14beta1
@see #trackColumnsForAutoSizing(Collection)
@see #trackAllColumnsForAutoSizing()
Track several columns in the sheet for auto-sizing.
Note this has undefined behavior if columns are tracked after one or more rows are written to the sheet.
Any column in columns
that are already tracked are ignored by this call.
@param columns the columns to track for autosizing
@since 3.14beta1
Tracks all columns in the sheet for auto-sizing. If this is called, individual columns do not need to be tracked.
Because determining the best-fit width for a cell is expensive, this may affect the performance.
@since 3.14beta1
Removes a column that was previously marked for inclusion in auto-size column tracking.
When a column is untracked, the best-fit width is forgotten.
If column
is not tracked, it will be ignored by this call.
@param column the index of the column to track for auto-sizing
@return true if column was tracked prior to this call, false if no action was taken
@since 3.14beta1
@see #untrackColumnsForAutoSizing(Collection)
@see #untrackAllColumnsForAutoSizing(int)
Untracks several columns in the sheet for auto-sizing.
When a column is untracked, the best-fit width is forgotten.
Any column in columns
that is not tracked will be ignored by this call.
@param columns the indices of the columns to track for auto-sizing
@return true if one or more columns were untracked as a result of this call
@param columns the columns to track for autosizing
@since 3.14beta1
Untracks all columns in the sheet for auto-sizing. Best-fit column widths are forgotten.
If this is called, individual columns do not need to be untracked.
@since 3.14beta1
Returns true if column is currently tracked for auto-sizing.
@param column the index of the column to check
@return true if column is tracked
@since 3.14beta1
Get the currently tracked columns for auto-sizing.
Note if all columns are tracked, this will only return the columns that have been explicitly or implicitly tracked,
which is probably only columns containing 1 or more non-blank values
@return a set of the indices of all tracked columns
@since 3.14beta1
@param rowIndex the zero based row index to find from
Are all rows flushed to disk?
@return Last row number to be flushed to disk, or -1 if none flushed yet
Specifies how many rows can be accessed at most via getRow().
The exeeding rows (if any) are flushed to the disk while rows
with lower index values are flushed first.
Streaming version of XSSFWorkbook implementing the "BigGridDemo" strategy.
This allows to write very large files without running out of memory as only
a configurable portion of the rows are kept in memory at any one time.
You can provide a template workbook which is used as basis for the written
data.
See https://poi.apache.org/spreadsheet/how-to.html#sxssf for details.
Please note that there are still things that still may consume a large
amount of memory based on which features you are using, e.g. merged regions,
comments, ... are still only stored in memory and thus may require a lot of
memory if used extensively.
SXSSFWorkbook defaults to using inline strings instead of a shared strings
table. This is very efficient, since no document content needs to be kept in
memory, but is also known to produce documents that are incompatible with
some clients. With shared strings enabled all unique strings in the document
has to be kept in memory. Depending on your document content this could use
a lot more resources than with shared strings disabled.
Carefully review your memory budget and compatibility needs before deciding
whether to enable shared strings or not.
Streaming version of the XSSFWorkbook, originally implemented in the "BigGridDemo".
See the constructors for a more detailed description of the sliding window of rows.
@return The number of rows that are kept in memory at once before flushing them out.
whether temp file should be compresss.
shared string table - a cache of strings in this workbook.
Construct an empty workbook and specify the window for row access.
When a new node is created via createRow() and the total number
of unflushed records would exceed the specified value, then the
row with the lowest index value is flushed and cannot be accessed
via getRow() anymore.
A value of -1 indicates unlimited access. In this case all
records that have not been flushed by a call to flush() are available
for random access.
A value of 0 is not allowed because it would flush any newly created row
without having a chance to specify any cells.
@param rowAccessWindowSize the number of rows that are kept in memory until flushed out, see above.
Construct a new workbook with default row window size
Construct a workbook from a template.
There are three use-cases to use SXSSFWorkbook(XSSFWorkbook) :
-
Append new sheets to existing workbooks. You can open existing
workbook from a file or create on the fly with XSSF.
-
Append rows to existing sheets. The row number MUST be greater
than max(rownum) in the template sheet.
-
Use existing workbook as a template and re-use global objects such
as cell styles, formats, images, etc.
All three use cases can work in a combination.
What is not supported:
-
Access initial cells and rows in the template. After constructing
SXSSFWorkbook(XSSFWorkbook) all internal windows are empty and
SXSSFSheet@getRow and SXSSFRow#getCell return null.
-
Override existing cells and rows. The API silently allows that but
the output file is invalid and Excel cannot read it.
@param workbook the template workbook
Constructs an workbook from an existing workbook.
When a new node is created via createRow() and the total number
of unflushed records would exceed the specified value, then the
row with the lowest index value is flushed and cannot be accessed
via getRow() anymore.
A value of -1 indicates unlimited access. In this case all
records that have not been flushed by a call to flush() are available
for random access.
A value of 0 is not allowed because it would flush any newly created row
without having a chance to specify any cells.
@param rowAccessWindowSize the number of rows that are kept in memory until flushed out, see above.
Constructs an workbook from an existing workbook.
When a new node is created via createRow() and the total number
of unflushed records would exceed the specified value, then the
row with the lowest index value is flushed and cannot be accessed
via getRow() anymore.
A value of -1 indicates unlimited access. In this case all
records that have not been flushed by a call to flush() are available
for random access.
A value of 0 is not allowed because it would flush any newly created row
without having a chance to specify any cells.
@param rowAccessWindowSize the number of rows that are kept in memory until flushed out, see above.
@param compressTmpFiles whether to use gzip compression for temporary files
Constructs an workbook from an existing workbook.
When a new node is created via createRow() and the total number
of unflushed records would exceed the specified value, then the
row with the lowest index value is flushed and cannot be accessed
via getRow() anymore.
A value of -1 indicates unlimited access. In this case all
records that have not been flushed by a call to flush() are available
for random access.
A value of 0 is not allowed because it would flush any newly created row
without having a chance to specify any cells.
@param workbook the template workbook
@param rowAccessWindowSize the number of rows that are kept in memory until flushed out, see above.
@param compressTmpFiles whether to use gzip compression for temporary files
@param useSharedStringsTable whether to use a shared strings table
Currently only supports writing not reading. E.g. the number of rows returned from a worksheet will be wrong etc.
Set whether temp files should be compressed.
SXSSF writes sheet data in temporary files (a temp file per-sheet)
and the size of these temp files can grow to to a very large size,
e.g. for a 20 MB csv data the size of the temp xml file become few GB large.
If the "compress" flag is set to true
then the temporary XML is gzipped.
Please note the the "compress" option may cause performance penalty.
@param compress whether to compress temp files
Finds a font that matches the one with the supplied attributes
@return the font with the matched attributes or null
Dispose of temporary files backing this workbook on disk.
Calling this method will render the workbook unusable.
@return true if all temporary files were deleted successfully.
Returns all defined names with the given name.
@param name the name of the defined name
@return a list of the defined names with the specified name. An empty list is returned if none is found.
Returns all defined names
Returns all defined names
Remove the given defined name
the name to remove
Returns the spreadsheet version (EXCLE2007) of this workbook
Gets a bool value that indicates whether the date systems used in the workbook starts in 1904.
The default value is false, meaning that the workbook uses the 1900 date system,
where 1/1/1900 is the first day in the system.
True if the date systems used in the workbook starts in 1904
Internal POI use only - parent of XSSF and SXSSF Evaluation workbooks
XSSF doesn't use external sheet indexes, so when asked treat
it just as a local index
@return the external sheet index of the sheet with the given internal
index. Used by some of the more obscure formula and named range things.
Fairly easy on XSSF (we think...) since the internal and external
indices are the same
Return EvaluationName wrapper around the matching XSSFName (named range)
case-aware but case-insensitive named range in workbook
index of sheet if named range scope is limited to one sheet
if named range scope is global to the workbook, sheetIndex is -1.
If name is a named range in the workbook, returns
EvaluationName corresponding to that named range
Returns null if there is no named range with the same name and scope in the workbook
Return an external name (named range, function, user-defined function) Pxg
Returns the data table with the given name (case insensitive).
Tables are cached for performance (formula evaluation looks them up by name repeatedly).
After the first table lookup, adding or removing a table from the document structure will cause trouble.
This is meant to be used on documents whose structure is essentially static at the point formulas are evaluated.
@param name the data table name (case-insensitive)
@return The Data table in the workbook named name, or null if no table is named name.
@since 3.15 beta 2
Internal POI use only - parent of XSSF and SXSSF formula Evaluators
Turns a XSSFCell / SXSSFCell into a XSSFEvaluationCell
Returns a CellValue wrapper around the supplied ValueEval instance.
Holds data for a XSSF Line Chart
List of all data series.
Base class for all axis types.
@author Roman Kashitsyn
@author Roman Kashitsyn
@return new scatter chart data instance
@return factory instance
Represents a SpreadsheetML chart legend
@author Roman Kashitsyn
Underlaying CTLagend bean
Create a new SpreadsheetML chart legend
Set sensible default styling.
Return the underlying CTLegend bean.
@return the underlying CTLegend bean
Package private class with utility methods.
@author Roman Kashitsyn
Builds CTAxDataSource object content from POI ChartDataSource.
@param ctAxDataSource OOXML data source to build
@param dataSource POI data source to use
Builds CTNumDataSource object content from POI ChartDataSource
@param ctNumDataSource OOXML data source to build
@param dataSource POI data source to use
Holds data for a XSSF Line Chart
List of all data series.
Represents a SpreadsheetML manual layout.
@author Roman Kashitsyn
Underlaying CTManualLayout bean.
Create a new SpreadsheetML manual layout.
@param layout a Spreadsheet ML layout that should be used as base.
Create a new SpreadsheetML manual layout for chart.
@param chart a chart to create layout for.
Return the underlying CTManualLayout bean.
@return the underlying CTManualLayout bean.
Represents DrawingML scatter chart.
@author Roman Kashitsyn
List of all data series.
Package private ScatterChartSerie implementation.
Returns data source used for X axis values.
@return data source used for X axis values
Returns data source used for Y axis values.
@return data source used for Y axis values
@param useCache if true, cached results will be Added on plot
Value axis type.
@author Roman Kashitsyn
Cell Settings avaiable in the Format/Alignment tab
Creates a Cell Alignment from the supplied XML defInition
@param cellAlignment
Get the type of vertical alignment for the cell
@return the type of aligment
@see VerticalAlignment
Get the type of horizontal alignment for the cell
@return the type of aligment
@see HorizontalAlignment
Get the number of spaces to indent the text in the cell
@return indent - number of spaces
Whether the text should be wrapped
@return a bool value indicating if the text in a cell should be line-wrapped within the cell.
Access to low-level data
The enumeration value indicating the side being used for a cell border.
This element Contains border formatting information, specifying border defInition formats (left, right, top, bottom, diagonal)
for cells in the workbook.
Color is optional.
Creates a Cell Border from the supplied XML defInition
Creates a Cell Border from the supplied XML defInition
Creates a new, empty Cell Border.
You need to attach this to the Styles Table
Records the Themes Table that is associated with
the current font, used when looking up theme
based colours and properties.
Returns the underlying XML bean.
@return CT_Border
Get the type of border to use for the selected border
@param side - - where to apply the color defInition
@return borderstyle - the type of border to use. default value is NONE if border style is not Set.
@see BorderStyle
Set the type of border to use for the selected border
@param side - - where to apply the color defInition
@param style - border style
@see BorderStyle
Get the color to use for the selected border
@param side - where to apply the color defInition
@return color - color to use as XSSFColor. null if color is not set
Set the color to use for the selected border
@param side - where to apply the color defInition
@param color - the color to use
This element specifies fill formatting.
A cell fill consists of a background color, foreground color, and pattern to be applied across the cell.
Creates a CellFill from the supplied parts
@param fill - fill
Creates an empty CellFill
Get the background fill color.
@return fill color, null if color is not set
Set the background fill color represented as a indexed color value.
@param index
Set the background fill color represented as a {@link XSSFColor} value.
@param color
Get the foreground fill color.
@return XSSFColor - foreground color. null if color is not set
Set the foreground fill color as a indexed color value
@param index - the color to use
Set the foreground fill color represented as a {@link XSSFColor} value.
@param color - the color to use
get the fill pattern
@return fill pattern type. null if fill pattern is not set
set the fill pattern
@param patternType fill pattern to use
Returns the underlying XML bean.
@return CT_Fill
Parent class of all XSSF headers and footers.
Create an instance of XSSFHeaderFooter from the supplied XML bean
@param headerFooter
Returns the underlying CTHeaderFooter xml bean
@return the underlying CTHeaderFooter xml bean
Are fields currently being stripped from the text that this
{@link XSSFHeaderFooter} returns? Default is false, but can be Changed
Should fields (eg macros) be stripped from the text that this class
returns? Default is not to strip.
@param StripFields
Removes any fields (eg macros, page markers etc) from the string.
Normally used to make some text suitable for showing to humans, and the
resultant text should not normally be saved back into the document!
get the text representing the center part of this element
get the text representing the left part of this element
get the text representing the right part of this element
Helper class for dealing with the Column Settings on
a CT_Worksheet (the data part of a sheet).
Note - within POI, we use 0 based column indexes, but
the column defInitions in the XML are 1 based!
Returns the Column at the given 0 based index
Returns the Column at the given 1 based index.
POI default is 0 based, but the file stores
as 1 based.
Returns a view of the portion of this map whose keys are greater than (or
equal to, if inclusive is true) fromKey.
@see Sweep line algorithm
Does the column at the given 0 based index exist
in the supplied list of column defInitions?
Return the CT_Col at the given (0 based) column index,
creating it if required.
Split into left, center, right
Utility to update formulas and named ranges when a sheet name was Changed
@author Yegor Kozlov
Update sheet name in all formulas and named ranges.
Called from {@link XSSFWorkbook#setSheetName(int, String)}
The idea is to parse every formula and render it back to string
with the updated sheet name. This is done by parsing into Ptgs,
looking for ones with sheet references in them, and changing those
@param sheetIndex the 0-based index of the sheet being changed
@param oldName the old sheet name
@param newName the new sheet name
Parse cell formula and re-assemble it back using the specified FormulaRenderingWorkbook.
@param cell the cell to update
@param frwb the formula rendering workbbok that returns new sheet name
Parse formula in the named range and re-assemble it back using the specified FormulaRenderingWorkbook.
@param name the name to update
@param frwb the formula rendering workbbok that returns new sheet name
XSSF-specific code for working with ignored errors
Sets the XORed or hashed password
@param xobj the xmlbeans object which Contains the password attributes
@param password the password, if null, the password attributes will be Removed
@param hashAlgo the hash algorithm, if null the password will be XORed
@param prefix the prefix of the password attributes, may be null
Validates the password, i.e.
calculates the hash of the given password and Compares it against the stored hash
@param xobj the xmlbeans object which Contains the password attributes
@param password the password, if null the method will always return false,
even if there's no password Set
@param prefix the prefix of the password attributes, may be null
@return true, if the hashes match
@author Yegor Kozlov
Shift merged regions
@param startRow the row to start Shifting
@param endRow the row to end Shifting
@param n the number of rows to shift
@return an array of affected cell regions
Updated named ranges
Update formulas.
Update the formulas in specified row using the formula shifting policy specified by shifter
the row to update the formulas on
the formula shifting policy
Shift a formula using the supplied FormulaShifter
@param row the row of the cell this formula belongs to. Used to get a reference to the parent workbook.
@param formula the formula to shift
@param Shifter the FormulaShifter object that operates on the Parsed formula tokens
@return the Shifted formula if the formula was Changed,
null
if the formula wasn't modified
Shift the Hyperlink anchors (not the hyperlink text, even if the hyperlink
is of type LINK_DOCUMENT and refers to a cell that was shifted). Hyperlinks
do not track the content they point to.
@param shifter
*
* This class is a wrapper around the CTSingleXmlCell (Open Office XML Part 4:
* chapter 3.5.2.1)
*
*
* @author Roberto Manicardi
*
Gets the XSSFCell referenced by the R attribute or Creates a new one if cell doesn't exists
@return the referenced XSSFCell, null if the cell reference is invalid
This class is a wrapper around the CT_XmlColumnPr (Open Office XML Part 4:
chapter 3.5.1.7)
@author Roberto Manicardi
(see Open Office XML Part 4: chapter 3.5.1.3)
@return An integer representing the unique identifier of this column.
If the XPath is, for example, /Node1/Node2/Node3 and /Node1/Node2 is the common XPath for the table, the local XPath is /Node3
@return the local XPath
Specifies type of automatic numbered bullet points that should be applied to a paragraph.
(a), (b), (c), ...
(A), (B), (C), ...
a), b), c), ...
A), B), C), ...
a., b., c., ...
A., B., C., ...
(1), (2), (3), ...
1), 2), 3), ...
1., 2., 3., ...
1, 2, 3, ...
(i), (ii), (iii), ...
(I), (II), (III), ...
i), ii), iii), ...
I), II), III), ...
i., ii., iii., ...
I., II., III., ...
Dbl-byte circle numbers
Wingdings black circle numbers
Wingdings white circle numbers
Specified a list of text alignment types
Align text to the left margin.
Align text in the center.
Align text to the right margin.
Align text so that it is justified across the whole line. It
is smart in the sense that it will not justify sentences
which are short
Specifies a list of auto-fit types.
Autofit specifies that a shape should be auto-fit to fully contain the text described within it.
Auto-fitting is when text within a shape is scaled in order to contain all the text inside
Specifies that text within the text body should not be auto-fit to the bounding box.
Auto-fitting is when text within a text box is scaled in order to remain inside
the text box.
Specifies that text within the text body should be normally auto-fit to the bounding box.
Autofitting is when text within a text box is scaled in order to remain inside the text box.
Example: Consider the situation where a user is building a diagram and needs
to have the text for each shape that they are using stay within the bounds of the shape.
An easy way this might be done is by using NORMAL autofit
Specifies that a shape should be auto-fit to fully contain the text described within it.
Auto-fitting is when text within a shape is scaled in order to contain all the text inside.
Example: Consider the situation where a user is building a diagram and needs to have
the text for each shape that they are using stay within the bounds of the shape.
An easy way this might be done is by using SHAPE autofit
Text Capitalization that is to be applied to the text Run. This is a render-only
modification and does not affect the actual characters stored in the text Run.
Vertical Text Types
Horizontal text. This should be default.
Vertical orientation.
(each line is 90 degrees rotated clockwise, so it goes
from top to bottom; each next line is to the left from
the previous one).
Vertical orientation.
(each line is 270 degrees rotated clockwise, so it goes
from bottom to top; each next line is to the right from
the previous one).
Determines if all of the text is vertical
("one letter on top of another").
Specified a list of text font alignment types
Automatic alignment
Align text to the top.
Align text in the center.
Align text to the baseline.
Align text to the bottom.
Text Horizontal Overflow
When a big character does not fit into a line, allow a
horizontal overflow.
When a big character does not fit into a line, clip it at
the proper horizontal overflow.
Text Vertical Overflow
Overflow the text and pay no attention to top and bottom barriers.
Pay attention to top and bottom barriers. Use an
ellipsis to denote that there is text which is not visible.
Pay attention to top and bottom barriers. Provide no
indication that there is text which is not visible.
An anchor is what specifics the position of a shape within a client object
or within another containing shape.
@author Yegor Kozlov
Represents autofiltering for the specified worksheet.
@author Yegor Kozlov
@author Yegor Kozlov
High level representation of a cell in a row of a spreadsheet.
Cells can be numeric, formula-based or string-based (text). The cell type
specifies this. String cells cannot conatin numbers and numeric cells cannot
contain strings (at least according to our model). Client apps should do the
conversions themselves. Formula cells have the formula string, as well as
the formula result, which can be numeric or string.
Cells should have their number (0 based) before being Added to a row. Only
cells that have values should be Added.
the xml bean Containing information about the cell's location, value,
data type, formatting, and formula
the XSSFRow this cell belongs to
0-based column index
Table of strings shared across this workbook.
If two cells contain the same string, then the cell value is the same index into SharedStringsTable
Table of cell styles shared across all cells in a workbook.
Construct a XSSFCell.
@param row the parent row.
@param cell the xml bean Containing information about the cell.
Copy cell value, formula and style, from srcCell per cell copy policy
If srcCell is null, clears the cell value and cell style per cell copy policy
This does not shift references in formulas. Use {@link XSSFRowShifter} to shift references in formulas.
The cell to take value, formula and style from
The policy for copying the information, see {@link CellCopyPolicy}
if copy cell style and srcCell is from a different workbook
@return table of strings shared across this workbook
@return table of cell styles shared across this workbook
Returns the sheet this cell belongs to
@return the sheet this cell belongs to
Returns the row this cell belongs to
@return the row this cell belongs to
Get the value of the cell as a bool.
For strings, numbers, and errors, we throw an exception. For blank cells we return a false.
@return the value of the cell as a bool
@throws InvalidOperationException if the cell type returned by {@link #CellType}
is not CellType.Boolean, CellType.Blank or CellType.Formula
Set a bool value for the cell
@param value the bool value to Set this cell to. For formulas we'll Set the
precalculated value, for bools we'll Set its value. For other types we
will change the cell to a bool cell and Set its value.
Get the value of the cell as a number.
For strings we throw an exception. For blank cells we return a 0.
For formulas or error cells we return the precalculated value;
@return the value of the cell as a number
@throws InvalidOperationException if the cell type returned by {@link #CellType} is CellType.String
@exception NumberFormatException if the cell value isn't a parsable double
.
@see DataFormatter for turning this number into a string similar to that which Excel would render this number as.
Set a numeric value for the cell
@param value the numeric value to Set this cell to. For formulas we'll Set the
precalculated value, for numerics we'll Set its value. For other types we
will change the cell to a numeric cell and Set its value.
Get the value of the cell as a string
For numeric cells we throw an exception. For blank cells we return an empty string.
For formulaCells that are not string Formulas, we throw an exception
@return the value of the cell as a string
Get the value of the cell as a XSSFRichTextString
For numeric cells we throw an exception. For blank cells we return an empty string.
For formula cells we return the pre-calculated value if a string, otherwise an exception
@return the value of the cell as a XSSFRichTextString
Set a string value for the cell.
@param str value to Set the cell to. For formulas we'll Set the formula
cached string result, for String cells we'll Set its value. For other types we will
change the cell to a string cell and Set its value.
If value is null then we will change the cell to a Blank cell.
Set a string value for the cell.
@param str value to Set the cell to. For formulas we'll Set the 'pre-Evaluated result string,
for String cells we'll Set its value. For other types we will
change the cell to a string cell and Set its value.
If value is null then we will change the cell to a Blank cell.
Return a formula for the cell, for example, SUM(C4:E4)
package/hierarchy use only - reuse an existing evaluation workbook if available for caching
@param fpb evaluation workbook for reuse, if available, or null to create a new one as needed
@return a formula for the cell
@throws InvalidOperationException if the cell type returned by {@link #getCellType()} is not CELL_TYPE_FORMULA
Creates a non shared formula from the shared formula counterpart
Shared Group Index
non shared formula created for the given shared formula and this cell
Sets formula for this cell.
Note, this method only Sets the formula string and does not calculate the formula value.
To Set the precalculated value use {@link #setCellValue(double)} or {@link #setCellValue(String)}
@param formula the formula to Set, e.g. "SUM(C4:E4)"
.
If the argument is null
then the current formula is Removed.
@throws NPOI.ss.formula.FormulaParseException if the formula has incorrect syntax or is otherwise invalid
@throws InvalidOperationException if the operation is not allowed, for example,
when the cell is a part of a multi-cell array formula
Returns zero-based column index of this cell
Returns zero-based row index of a row in the sheet that contains this cell
Returns an A1 style reference to the location of this cell
A1 style reference to the location of this cell
Return the cell's style.
Return the cell type.
Only valid for formula cells
Detect cell type based on the "t" attribute of the CT_Cell bean
Get the value of the cell as a date.
Set a date value for the cell. Excel treats dates as numeric so you will need to format the cell as a date.
the date value to Set this cell to. For formulas we'll set the precalculated value,
for numerics we'll Set its value. For other types we will change the cell to a numeric cell and Set its value.
Returns the error message, such as #VALUE!
Get the value of the cell as an error code.
For strings, numbers, and bools, we throw an exception.
For blank cells we return a 0.
Set a error value for the cell
the error value to Set this cell to.
For formulas we'll Set the precalculated value , for errors we'll set
its value. For other types we will change the cell to an error cell and Set its value.
Sets this cell as the active cell for the worksheet.
Blanks this cell. Blank cells have no formula or value but may have styling.
This method erases all the data previously associated with this cell.
Sets column index of this cell
Set the cells type (numeric, formula or string)
Returns a string representation of the cell
Formula cells return the formula string, rather than the formula result.
Dates are displayed in dd-MMM-yyyy format
Errors are displayed as #ERR<errIdx>
Returns the raw, underlying ooxml value for the cell
If the cell Contains a string, then this value is an index into
the shared string table, pointing to the actual string value. Otherwise,
the value of the cell is expressed directly in this element. Cells Containing formulas express
the last calculated result of the formula in this element.
@return the raw cell value as Contained in the underlying CT_Cell bean,
null
for blank cells.
Used to help format error messages
Used to help format error messages
@throws RuntimeException if the bounds are exceeded.
Returns cell comment associated with this cell
Removes the comment for this cell, if there is one.
Get or set hyperlink associated with this cell
If the supplied hyperlink is null on setting, the hyperlink for this cell will be removed.
Removes the hyperlink for this cell, if there is one.
Returns the xml bean containing information about the cell's location (reference), value,
data type, formatting, and formula
@return the xml bean containing information about this cell
Chooses a new bool value for the cell when its type is changing.
Usually the caller is calling SetCellType() with the intention of calling
SetCellValue(bool) straight afterwards. This method only exists to give
the cell a somewhat reasonable value until the SetCellValue() call (if at all).
TODO - perhaps a method like SetCellTypeAndValue(int, Object) should be introduced to avoid this
The purpose of this method is to validate the cell state prior to modification
@see #NotifyArrayFormulaChanging()
Called when this cell is modified.The purpose of this method is to validate the cell state prior to modification.
if modification is not allowed
High level representation of the the possible formatting information for the contents of the cells on a sheet in a
SpreadsheetML document.
@see NPOI.xssf.usermodel.XSSFWorkbook#CreateCellStyle()
@see NPOI.xssf.usermodel.XSSFWorkbook#getCellStyleAt(short)
@see NPOI.xssf.usermodel.XSSFCell#setCellStyle(NPOI.ss.usermodel.CellStyle)
Creates a Cell Style from the supplied parts
@param cellXfId The main XF for the cell. Must be a valid 0-based index into the XF table
@param cellStyleXfId Optional, style xf. A value of -1
means no xf.
@param stylesSource Styles Source to work off
Used so that StylesSource can figure out our location
Used so that StylesSource can figure out our location
Creates an empty Cell Style
Verifies that this style belongs to the supplied Workbook
Styles Source.
Will throw an exception if it belongs to a different one.
This is normally called when trying to assign a style to a
cell, to ensure the cell and the style are from the same
workbook (if they're not, it won't work)
@throws ArgumentException if there's a workbook mis-match
Clones all the style information from another
XSSFCellStyle, onto this one. This
XSSFCellStyle will then have all the same
properties as the source, but the two may
be edited independently.
Any stylings on this XSSFCellStyle will be lost!
The source XSSFCellStyle could be from another
XSSFWorkbook if you like. This allows you to
copy styles from one XSSFWorkbook to another.
Get the type of horizontal alignment for the cell
the type of alignment
Get or set the type of border to use for the bottom border of the cell
Get or set the type of border to use for the left border of the cell
Get or set the type of border to use for the right border of the cell
Get or set the type of border to use for the top border of the cell
Get the color to use for the bottom border
Color is optional. When missing, IndexedColors.Automatic is implied.
@return the index of the color defInition, default value is {@link NPOI.ss.usermodel.IndexedColors#AUTOMATIC}
@see NPOI.ss.usermodel.IndexedColors
Get the color to use for the bottom border as a {@link XSSFColor}
@return the used color or null
if not Set
Get the index of the number format (numFmt) record used by this cell format.
@return the index of the number format
Set the index of a data format
@param fmt the index of a data format
Get the contents of the format string, by looking up
the StylesSource
@return the number format string
Get the background fill color.
Note - many cells are actually filled with a foreground fill, not a background fill
Get the background fill color.
Note - many cells are actually Filled with a foreground
Fill, not a background fill - see {@link #getFillForegroundColor()}
@see NPOI.xssf.usermodel.XSSFColor#getRgb()
@return XSSFColor - fill color or null
if not Set
Get the foreground fill color.
Many cells are Filled with this, instead of a
background color ({@link #getFillBackgroundColor()})
@see IndexedColors
@return fill color, default value is {@link NPOI.ss.usermodel.IndexedColors#AUTOMATIC}
Get the foreground fill color.
Get the foreground fill color.
Gets the font for this style
@return Font - font
Gets the index of the font for this style
@return short - font index
@see NPOI.xssf.usermodel.XSSFWorkbook#getFontAt(short)
Get whether the cell's using this style are to be hidden
@return bool - whether the cell using this style is hidden
Get the number of spaces to indent the text in the cell
@return indent - number of spaces
Get the index within the StylesTable (sequence within the collection of CT_Xf elements)
@return unique index number of the underlying record this style represents
Get the color to use for the left border
@return the index of the color defInition, default value is {@link NPOI.ss.usermodel.IndexedColors#BLACK}
@see NPOI.ss.usermodel.IndexedColors
Get the color to use for the left border
@return the index of the color defInition or null
if not Set
@see NPOI.ss.usermodel.IndexedColors
Get whether the cell's using this style are locked
Get the color to use for the right border
Get the color to use for the right border
Get the degree of rotation (between 0 and 180 degrees) for the text in the cell
Note: HSSF uses values from -90 to 90 degrees, whereas XSSF
uses values from 0 to 180 degrees.The implementations of this method will map between these two value-ranges
accordingly, however the corresponding getter is returning values in the range mandated by the current type
of Excel file-format that this CellStyle is applied to.
Expressed in degrees. Values range from 0 to 180. The first letter of
the text is considered the center-point of the arc.
For 0 - 90, the value represents degrees above horizon. For 91-180 the degrees below the horizon is calculated as:
[degrees below horizon] = 90 - textRotation.
Get the color to use for the top border
@return the index of the color defInition, default value is {@link NPOI.ss.usermodel.IndexedColors#BLACK}
@see NPOI.ss.usermodel.IndexedColors
Get the color to use for the top border
Get the type of vertical alignment for the cell
Get the type of vertical alignment for the cell
Whether the text in a cell should be line-wrapped within the cell.
Set the color to use for the bottom border
@param color the color to use, null means no color
* Set the foreground fill color represented as a {@link XSSFColor} value.
*
* Note: Ensure Foreground color is Set prior to background color.
* @param color the color to use
* @see #setFillBackgroundColor(NPOI.xssf.usermodel.XSSFColor) )
Get a copy of the currently used CT_Fill, if none is used, return a new instance.
Get a copy of the currently used CT_Border, if none is used, return a new instance.
Set the font for this style
@param font a font object Created or retrieved from the XSSFWorkbook object
@see NPOI.xssf.usermodel.XSSFWorkbook#CreateFont()
@see NPOI.xssf.usermodel.XSSFWorkbook#getFontAt(short)
Set the color to use for the left border as a {@link XSSFColor} value
@param color the color to use
Set the color to use for the right border as a {@link XSSFColor} value
@param color the color to use
Set the color to use for the top border as a {@link XSSFColor} value
@param color the color to use
Set the type of vertical alignment for the cell
@param align - align the type of alignment
@see NPOI.ss.usermodel.CellStyle#VERTICAL_TOP
@see NPOI.ss.usermodel.CellStyle#VERTICAL_CENTER
@see NPOI.ss.usermodel.CellStyle#VERTICAL_BOTTOM
@see NPOI.ss.usermodel.CellStyle#VERTICAL_JUSTIFY
@see NPOI.ss.usermodel.VerticalAlignment
Gets border color
@param side the border side
@return the used color
Set the color to use for the selected border
@param side - where to apply the color defInition
@param color - the color to use
Get the cellAlignment object to use for manage alignment
@return XSSFCellAlignment - cell alignment
Return the CT_CellAlignment instance for alignment
@return CT_CellAlignment
Returns a hash code value for the object. The hash is derived from the underlying CT_Xf bean.
@return the hash code value for this style
Checks is the supplied style is equal to this style
@param o the style to check
@return true if the supplied style is equal to this style
Make a copy of this style. The underlying CT_Xf bean is Cloned,
the references to Fills and borders remain.
@return a copy of this style
Represents a SpreadsheetML Chart
@author Nick Burch
@author Roman Kashitsyn
Parent graphic frame.
Root element of the SpreadsheetML Chart part
The Chart within that
Create a new SpreadsheetML chart
Construct a SpreadsheetML chart from a namespace part.
@param part the namespace part holding the chart data,
the content type must be application/vnd.Openxmlformats-officedocument.Drawingml.chart+xml
@param rel the namespace relationship holding this chart,
the relationship type must be http://schemas.Openxmlformats.org/officeDocument/2006/relationships/chart
Construct a new CTChartSpace bean.
By default, it's just an empty placeholder for chart objects.
@return a new CTChartSpace bean
Return the underlying CTChartSpace bean, the root element of the SpreadsheetML Chart part.
@return the underlying CTChartSpace bean
Return the underlying CTChart bean, within the Chart Space
@return the underlying CTChart bean
Returns the parent graphic frame.
@return the graphic frame this chart belongs to
Sets the parent graphic frame.
@return true if only visible cells will be present on the chart,
false otherwise
@param plotVisOnly a flag specifying if only visible cells should be
present on the chart
Returns the title, or null if none is Set
Sets the title text.
High level representation of Sheet Parts that are of type 'chartsheet'.
Chart sheet is a special kind of Sheet that Contains only chart and no data.
@author Yegor Kozlov
@since POI 3.14-Beta1
Provide access to the CTChartsheet bean holding this sheet's data
@return the CTChartsheet bean holding this sheet's data
A client anchor is attached to an excel worksheet. It anchors against
top-left and bottom-right cells.
@author Yegor Kozlov
Starting anchor point
Ending anchor point
Creates a new client anchor and defaults all the anchor positions to 0.
Creates a new client anchor and Sets the top-left and bottom-right
coordinates of the anchor.
@param dx1 the x coordinate within the first cell.
@param dy1 the y coordinate within the first cell.
@param dx2 the x coordinate within the second cell.
@param dy2 the y coordinate within the second cell.
@param col1 the column (0 based) of the first cell.
@param row1 the row (0 based) of the first cell.
@param col2 the column (0 based) of the second cell.
@param row2 the row (0 based) of the second cell.
Create XSSFClientAnchor from existing xml beans
@param cell1 starting anchor point
@param cell2 ending anchor point
Return starting anchor point
@return starting anchor point
Return ending anchor point
@return ending anchor point
Represents a color in SpreadsheetML
Create an instance of XSSFColor from the supplied XML bean
Create an new instance of XSSFColor
A bool value indicating the ctColor is automatic and system ctColor dependent.
A bool value indicating if the ctColor has a alpha or not
A bool value indicating if the ctColor has a tint or not
Indexed ctColor value. Only used for backwards compatibility. References a ctColor in indexedColors.
Standard Red Green Blue ctColor value (RGB).
If there was an A (Alpha) value, it will be stripped.
Standard Alpha Red Green Blue ctColor value (ARGB).
Standard Alpha Red Green Blue ctColor value (ARGB).
Standard Red Green Blue ctColor value (RGB) with applied tint.
Alpha values are ignored.
Standard Alpha Red Green Blue ctColor value (ARGB).
Index into the clrScheme collection, referencing a particular sysClr or
srgbClr value expressed in the Theme part.
Specifies the tint value applied to the ctColor.
If tint is supplied, then it is applied to the RGB value of the ctColor to determine the final
ctColor applied.
The tint value is stored as a double from -1.0 .. 1.0, where -1.0 means 100% darken and
1.0 means 100% lighten. Also, 0.0 means no Change.
In loading the RGB value, it is Converted to HLS where HLS values are (0..HLSMAX), where
HLSMAX is currently 255.
Here are some examples of how to apply tint to ctColor:
If (tint < 0)
Lum' = Lum * (1.0 + tint)
For example: Lum = 200; tint = -0.5; Darken 50%
Lum' = 200 * (0.5) => 100
For example: Lum = 200; tint = -1.0; Darken 100% (make black)
Lum' = 200 * (1.0-1.0) => 0
If (tint > 0)
Lum' = Lum * (1.0-tint) + (HLSMAX - HLSMAX * (1.0-tint))
For example: Lum = 100; tint = 0.75; Lighten 75%
Lum' = 100 * (1-.75) + (HLSMAX - HLSMAX*(1-.75))
= 100 * .25 + (255 - 255 * .25)
= 25 + (255 - 63) = 25 + 192 = 217
For example: Lum = 100; tint = 1.0; Lighten 100% (make white)
Lum' = 100 * (1-1) + (HLSMAX - HLSMAX*(1-1))
= 100 * 0 + (255 - 255 * 0)
= 0 + (255 - 0) = 255
@return the tint value
Returns the underlying XML bean
@return the underlying XML bean
Checked type cast color to an XSSFColor.
the color to type cast
the type casted color
if color is null or is not an instance of XSSFColor
High level representation for Color Scale / Color Gradient Formatting
component of Conditional Formatting Settings
cached reference to the string with the comment text
Creates a new XSSFComment, associated with a given
low level comment object.
@return Name of the original comment author. Default value is blank.
@return the 0-based column of the cell that the comment is associated with.
@return the 0-based row index of the cell that the comment is associated with.
@return whether the comment is visible
@return the rich text string of the comment
Sets the rich text string used by this comment.
@param string the XSSFRichTextString used by this object.
@return the xml bean holding this comment's properties
@author Yegor Kozlov
@return array of CellRangeAddresss. Never null
Replaces an existing Conditional Formatting rule at position idx.
Excel allows to create up to 3 Conditional Formatting rules.
This method can be useful to modify existing Conditional Formatting rules.
@param idx position of the rule. Should be between 0 and 2.
@param cfRule - Conditional Formatting rule
Add a Conditional Formatting rule.
Excel allows to create up to 3 Conditional Formatting rules.
@param cfRule - Conditional Formatting rule
@return the Conditional Formatting rule at position idx.
@return number of Conditional Formatting rules.
@author Yegor Kozlov
Create a new border formatting structure if it does not exist,
otherwise just return existing object.
@return - border formatting object, never returns null
.
@return - border formatting object if defined, null
otherwise
Create a new font formatting structure if it does not exist,
otherwise just return existing object.
@return - font formatting object, never returns null
.
@return - font formatting object if defined, null
otherwise
Create a new pattern formatting structure if it does not exist,
otherwise just return existing object.
@return - pattern formatting object, never returns null
.
@return - pattern formatting object if defined, null
otherwise
Type of conditional formatting rule.
The comparison function used when the type of conditional formatting is Set to
{@link ConditionalFormattingRule#CONDITION_TYPE_CELL_VALUE_IS}
MUST be a constant from {@link NPOI.ss.usermodel.ComparisonOperator}
@return the conditional format operator
The formula used to Evaluate the first operand for the conditional formatting rule.
If the condition type is {@link ConditionalFormattingRule#CONDITION_TYPE_CELL_VALUE_IS},
this field is the first operand of the comparison.
If type is {@link ConditionalFormattingRule#CONDITION_TYPE_FORMULA}, this formula is used
to determine if the conditional formatting is applied.
If comparison type is {@link ConditionalFormattingRule#CONDITION_TYPE_FORMULA} the formula MUST be a Boolean function
@return the first formula
The formula used to Evaluate the second operand of the comparison when
comparison type is {@link ConditionalFormattingRule#CONDITION_TYPE_CELL_VALUE_IS} and operator
is either {@link NPOI.ss.usermodel.ComparisonOperator#BETWEEN} or {@link NPOI.ss.usermodel.ComparisonOperator#NOT_BETWEEN}
@return the second formula
High level representation for Icon / Multi-State / Databar /
Colour Scale change thresholds
A connection shape Drawing element. A connection shape is a line, etc.
that connects two other shapes in this Drawing.
@author Yegor Kozlov
Construct a new XSSFConnector object.
@param Drawing the XSSFDrawing that owns this shape
@param ctShape the shape bean that holds all the shape properties
Initialize default structure of a new auto-shape
Gets the shape type, one of the constants defined in {@link NPOI.ss.usermodel.ShapeTypes}.
@return the shape type
@see NPOI.ss.usermodel.ShapeTypes
Creates a new XSSFRichTextString for you.
Creates a XSSFFormulaEvaluator, the object that Evaluates formula cells.
@return a XSSFFormulaEvaluator instance
Creates a XSSFClientAnchor. Use this object to position Drawing object in
a sheet
@return a XSSFClientAnchor instance
@see NPOI.ss.usermodel.Drawing
High level representation for DataBar / Data Bar Formatting
component of Conditional Formatting Settings
Handles data formats for XSSF.
Per Microsoft Excel 2007+ format limitations:
Workbooks support between 200 and 250 "number formats"
(POI calls them "data formats") So short or even byte
would be acceptable data types to use for referring to
data format indices.
https://support.office.com/en-us/article/excel-specifications-and-limits-1672b34d-7043-467e-8e27-269d656771c3
Get the format index that matches the given format
string, creating a new format entry if required.
Aliases text to the proper format as required.
@param format string matching a built in format
@return index of format.
Get the format string that matches the given format index
@param index of a format
@return string represented at index of format or null if there is not a format at that index
get the format string that matches the given format index
@param index of a format
@return string represented at index of format or null if there is not a format at that index
Add a number format with a specific ID into the number format style table.
If a format with the same ID already exists, overwrite the format code
with fmt
This may be used to override built-in number formats.
@param index the number format ID
@param format the number format code
@author Radhakrishnan J
@author Radhakrishnan J
Excel validation constraints with static lists are delimited with optional whitespace and the Windows List Separator,
which is typically comma, but can be changed by users. POI will just assume comma.
This is the constructor called using the OOXML raw data. Excel overloads formula1 to also encode explicit value lists,
so this constructor has to check for and parse that syntax.
Overloaded: formula1 or list of explicit values
formula1 is a list of explicit values, this is ignored: use null
@author Radhakrishnan J
Represents a SpreadsheetML Drawing
@author Yegor Kozlov
Root element of the SpreadsheetML Drawing part
Create a new SpreadsheetML Drawing
@see NPOI.xssf.usermodel.XSSFSheet#CreateDrawingPatriarch()
Construct a SpreadsheetML Drawing from a namespace part
@param part the namespace part holding the Drawing data,
the content type must be application/vnd.openxmlformats-officedocument.Drawing+xml
@param rel the namespace relationship holding this Drawing,
the relationship type must be http://schemas.openxmlformats.org/officeDocument/2006/relationships/drawing
Construct a new CT_Drawing bean. By default, it's just an empty placeholder for Drawing objects
@return a new CT_Drawing bean
Return the underlying CT_Drawing bean, the root element of the SpreadsheetML Drawing part.
@return the underlying CT_Drawing bean
Constructs a textbox under the Drawing.
@param anchor the client anchor describes how this group is attached
to the sheet.
@return the newly Created textbox.
Creates a picture.
@param anchor the client anchor describes how this picture is attached to the sheet.
@param pictureIndex the index of the picture in the workbook collection of pictures,
{@link NPOI.xssf.usermodel.XSSFWorkbook#getAllPictures()} .
@return the newly Created picture shape.
Creates a chart.
the client anchor describes how this chart is attached to
the newly created chart
Add the indexed picture to this Drawing relations
@param pictureIndex the index of the picture in the workbook collection of pictures,
{@link NPOI.xssf.usermodel.XSSFWorkbook#getAllPictures()} .
Creates a simple shape. This includes such shapes as lines, rectangles,
and ovals.
@param anchor the client anchor describes how this group is attached
to the sheet.
@return the newly Created shape.
Creates a simple shape. This includes such shapes as lines, rectangles,
and ovals.
@param anchor the client anchor describes how this group is attached
to the sheet.
@return the newly Created shape.
Creates a simple shape. This includes such shapes as lines, rectangles,
and ovals.
@param anchor the client anchor describes how this group is attached
to the sheet.
@return the newly Created shape.
Creates a comment.
@param anchor the client anchor describes how this comment is attached
to the sheet.
@return the newly Created comment.
Creates a new graphic frame.
@param anchor the client anchor describes how this frame is attached
to the sheet
@return the newly Created graphic frame
Returns all charts in this Drawing.
Create and Initialize a CT_TwoCellAnchor that anchors a shape against top-left and bottom-right cells.
@return a new CT_TwoCellAnchor
@return list of shapes in this drawing
XSSF wrapper for a cell under Evaluation
@author Josh Micich
XSSF wrapper for a sheet under Evaluation
@author Josh Micich
Internal POI use only
@author Josh Micich
Even page footer value. Corresponds to even printed pages.
Even page(s) in the sheet may not be printed, for example, if the print area is specified to be
a range such that it falls outside an even page's scope.
If no even footer is specified, then the odd footer's value is assumed for even page footers.
Create an instance of XSSFEvenFooter from the supplied XML bean
@see XSSFSheet#GetEvenFooter()
@param headerFooter
Get the content text representing the footer
@return text
Even page header value. Corresponds to even printed pages.
Even page(s) in the sheet may not be printed, for example, if the print area is specified to be
a range such that it falls outside an even page's scope.
If no even header is specified, then odd header value is assumed for even page headers.
Create an instance of XSSFEvenHeader from the supplied XML bean
@see XSSFSheet#GetEvenHeader()
@param headerFooter
Get the content text representing this header
@return text
Instantiates sub-classes of POIXMLDocumentPart depending on their relationship type
@author Yegor Kozlov
@since POI 3.14-Beta1
@since POI 3.14-Beta1
First page footer content. Corresponds to first printed page.
The first logical page in the sheet may not be printed, for example, if the print area is specified to
be a range such that it falls outside the first page's scope.
Create an instance of XSSFFirstFooter from the supplied XML bean
@see XSSFSheet#getFirstFooter()
@param headerFooter
Get the content text representing the footer
@return text
First page header content. Corresponds to first printed page.
The first logical page in the sheet may not be printed, for example, if the print area is specified to
be a range such that it falls outside the first page's scope.
Create an instance of XSSFFirstHeader from the supplied XML bean
@see XSSFSheet#getFirstHeader()
@param headerFooter
Get the content text representing this header
@return text
Represents a font used in a workbook.
@author Gisella Bronzetti
By default, Microsoft Office Excel 2007 uses the Calibry font in font size 11
By default, Microsoft Office Excel 2007 uses the Calibry font in font size 11
Default font color is black
@see NPOI.SS.usermodel.IndexedColors#BLACK
Create a new XSSFFont
@param font the underlying CT_Font bean
Create a new XSSFont. This method is protected to be used only by XSSFWorkbook
get the underlying CT_Font font
get a bool value for the boldness to use.
@return bool - bold
get character-set to use.
@return int - character-set (0-255)
@see NPOI.SS.usermodel.FontCharset
get the indexed color value for the font
References a color defined in IndexedColors.
@return short - indexed color to use
@see IndexedColors
get the color value for the font
References a color defined as Standard Alpha Red Green Blue color value (ARGB).
@return XSSFColor - rgb color to use
get the color value for the font
References a color defined in theme.
@return short - theme defined to use
Get the font height in unit's of 1/20th of a point.
Get the font height in points.
get the name of the font (i.e. Arial)
@return String - a string representing the name of the font to use
get a bool value that specify whether to use italics or not
@return bool - value for italic
get a bool value that specify whether to use a strikeout horizontal line through the text or not
@return bool - value for strikeout
get normal,super or subscript.
@return short - offset type to use (none,super,sub)
@see Font#SS_NONE
@see Font#SS_SUPER
@see Font#SS_SUB
get type of text underlining to use
@return byte - underlining type
@see NPOI.SS.usermodel.FontUnderline
get the boldness to use
@return boldweight
@see #BOLDWEIGHT_NORMAL
@see #BOLDWEIGHT_BOLD
set character-set to use.
@param charset - charset
@see FontCharset
set character-set to use.
@param charset - charset
@see FontCharset
set character-set to use.
@param charSet
set the color for the font in Standard Alpha Red Green Blue color value
@param color - color to use
set the theme color for the font to use
@param theme - theme color to use
set an enumeration representing the style of underlining that is used.
The none style is equivalent to not using underlining at all.
The possible values for this attribute are defined by the FontUnderline
@param underline - FontUnderline enum value
**
Records the Themes Table that is associated with
the current font, used when looking up theme
based colours and properties.
get the font scheme property.
is used only in StylesTable to create the default instance of font
@return FontScheme
@see NPOI.XSSF.model.StylesTable#CreateDefaultFont()
set font scheme property
@param scheme - FontScheme enum value
@see FontScheme
get the font family to use.
@return the font family to use
@see NPOI.SS.usermodel.FontFamily
set an enumeration representing the font family this font belongs to.
A font family is a set of fonts having common stroke width and serif characteristics.
@param family font family
@link #SetFamily(int value)
get the index within the XSSFWorkbook (sequence within the collection of Font objects)
@return unique index number of the underlying record this Font represents (probably you don't care
unless you're comparing which one is which)
@author Yegor Kozlov
Get the type of super or subscript for the font
@return super or subscript option
@see #SS_NONE
@see #SS_SUPER
@see #SS_SUB
@return font color index
Gets the height of the font in 1/20th point units
@return fontheight (in points/20); or -1 if not modified
Get the type of underlining for the font
@return font underlining type
@see #U_NONE
@see #U_SINGLE
@see #U_DOUBLE
@see #U_SINGLE_ACCOUNTING
@see #U_DOUBLE_ACCOUNTING
Get whether the font weight is Set to bold or not
@return bold - whether the font is bold or not
@return true if font style was Set to italic
Set font style options.
@param italic - if true, Set posture style to italic, otherwise to normal
@param bold if true, Set font weight to bold, otherwise to normal
Set font style options to default values (non-italic, non-bold)
Evaluates formula cells.
For performance reasons, this class keeps a cache of all previously calculated intermediate
cell values. Be sure to call {@link #ClearAllCachedResultValues()} if any workbook cells are Changed between
calls to Evaluate~ methods on this class.
@author Amol S. Deshmukh < amolweb at ya hoo dot com >
@author Josh Micich
@param stabilityClassifier used to optimise caching performance. Pass null
for the (conservative) assumption that any cell may have its defInition Changed After
Evaluation begins.
@param udfFinder pass null
for default (AnalysisToolPak only)
Loops over all cells in all sheets of the supplied
workbook.
For cells that contain formulas, their formulas are
Evaluated, and the results are saved. These cells
remain as formula cells.
For cells that do not contain formulas, no Changes
are made.
This is a helpful wrapper around looping over all
cells, and calling EvaluateFormulaCell on each one.
Loops over all cells in all sheets of the supplied
workbook.
For cells that contain formulas, their formulas are
Evaluated, and the results are saved. These cells
remain as formula cells.
For cells that do not contain formulas, no Changes
are made.
This is a helpful wrapper around looping over all
cells, and calling EvaluateFormulaCell on each one.
Turns a XSSFCell into a XSSFEvaluationCell
Represents DrawingML GraphicalObjectFrame.
@author Roman Kashitsyn
Construct a new XSSFGraphicFrame object.
@param Drawing the XSSFDrawing that owns this frame
@param ctGraphicFrame the XML bean that stores this frame content
Initialize default structure of a new graphic frame
Sets the frame macro.
Returns the frame name.
@return name of the frame
Returns the frame anchor.
@return the anchor this frame is attached to
Assign a DrawingML chart to the graphic frame.
Gets the frame id.
High level representation for Icon / Multi-State Formatting
component of Conditional Formatting Settings
Always . You cannot change text of a line break.
This class : the Map element (Open Office XML Part 4:
chapter 3.16.2)
This element Contains all of the properties related to the XML map,
and the behaviors expected during data refresh operations.
@author Roberto Manicardi
@return the list of Single Xml Cells that provide a map rule to this mapping.
@return the list of all Tables that provide a map rule to this mapping
Represents a defined named range in a SpreadsheetML workbook.
Defined names are descriptive text that is used to represents a cell, range of cells, formula, or constant value.
Use easy-to-understand names, such as Products, to refer to hard to understand ranges, such as Sales!C20:C30
.
Example:
XSSFWorkbook wb = new XSSFWorkbook();
XSSFSheet sh = wb.CreateSheet("Sheet1");
//applies to the entire workbook
XSSFName name1 = wb.CreateName();
name1.SetNameName("FMLA");
name1.SetRefersToFormula("Sheet1!$B$3");
//applies to Sheet1
XSSFName name2 = wb.CreateName();
name2.SetNameName("SheetLevelName");
name2.SetComment("This name is scoped to Sheet1");
name2.SetLocalSheetId(0);
name2.SetRefersToFormula("Sheet1!$B$3");
@author Nick Burch
@author Yegor Kozlov
A built-in defined name that specifies the workbook's print area
A built-in defined name that specifies the row(s) or column(s) to repeat
at the top of each printed page.
A built-in defined name that refers to a range Containing the criteria values
to be used in Applying an advanced filter to a range of data
this defined name refers to the range Containing the filtered
output values resulting from Applying an advanced filter criteria to a source
range
?an be one of the following
1 this defined name refers to a range to which an advanced filter has been
applied. This represents the source data range, unfiltered.
2 This defined name refers to a range to which an AutoFilter has been
applied
A built-in defined name that refers to a consolidation area
A built-in defined name that specified that the range specified is from a database data source
A built-in defined name that refers to a sheet title.
Creates an XSSFName object - called internally by XSSFWorkbook.
@param name - the xml bean that holds data represenring this defined name.
@param workbook - the workbook object associated with the name
@see NPOI.XSSF.usermodel.XSSFWorkbook#CreateName()
Returns the underlying named range object
Returns the name that will appear in the user interface for the defined name.
@return text name of this defined name
Returns the sheet index this name applies to.
@return the sheet index this name applies to, -1 if this name applies to the entire workbook
Indicates that the defined name refers to a user-defined function.
This attribute is used when there is an Add-in or other code project associated with the file.
@return true
indicates the name refers to a function.
Returns the function group index if the defined name refers to a function. The function
group defines the general category for the function. This attribute is used when there is
an Add-in or other code project associated with the file.
@return the function group index that defines the general category for the function
Get the sheets name which this named range is referenced to
@return sheet name, which this named range referred to.
Empty string if the referenced sheet name weas not found.
Is the name refers to a user-defined function ?
@return true
if this name refers to a user-defined function
Returns the comment the user provided when the name was Created.
@return the user comment for this named range
Compares this name to the specified object.
The result is true
if the argument is XSSFName and the
underlying CTDefinedName bean Equals to the CTDefinedName representing this name
@param o the object to compare this XSSFName
against.
@return true
if the XSSFName
are Equal;
false
otherwise.
XSSF Implementation of a Hyperlink.
Note - unlike with HSSF, many kinds of hyperlink
are largely stored as relations of the sheet
Create a new XSSFHyperlink. This method is protected to be used only by XSSFCreationHelper
@param type - the type of hyperlink to create
Create a XSSFHyperlink amd Initialize it from the supplied CTHyperlink bean and namespace relationship
@param ctHyperlink the xml bean Containing xml properties
@param hyperlinkRel the relationship in the underlying OPC namespace which stores the actual link's Address
Create a new XSSFHyperlink. This method is for Internal use only.
XSSFHyperlinks can be created by XSSFCreationHelper.
@param type - the type of hyperlink to create, see {@link Hyperlink}
@return the underlying CTHyperlink object
Do we need to a relation too, to represent
this hyperlink?
Generates the relation if required
Return the type of this hyperlink
@return the type of this hyperlink
Get the reference of the cell this applies to,
es A55
Hyperlink Address. Depending on the hyperlink type it can be URL, e-mail, path to a file
@return the Address of this hyperlink
Return text label for this hyperlink
@return text to display
Location within target. If target is a workbook (or this workbook) this shall refer to a
sheet and cell or a defined name. Can also be an HTML anchor if target is HTML file.
@return location
Assigns this hyperlink to the given cell reference
Return the column of the first cell that Contains the hyperlink
@return the 0-based column of the first cell that Contains the hyperlink
Return the column of the last cell that Contains the hyperlink
For XSSF, a Hyperlink may only reference one cell
@return the 0-based column of the last cell that Contains the hyperlink
Return the row of the first cell that Contains the hyperlink
@return the 0-based row of the cell that Contains the hyperlink
Return the row of the last cell that Contains the hyperlink
For XSSF, a Hyperlink may only reference one cell
@return the 0-based row of the last cell that Contains the hyperlink
get or set additional text to help the user understand more about the hyperlink
Odd page footer value. Corresponds to odd printed pages.
Odd page(s) in the sheet may not be printed, for example, if the print area is specified to be
a range such that it falls outside an odd page's scope.
Create an instance of XSSFOddFooter from the supplied XML bean
@see XSSFSheet#GetOddFooter()
@param headerFooter
Get the content text representing the footer
@return text
Odd page header value. Corresponds to odd printed pages.
Odd page(s) in the sheet may not be printed, for example, if the print area is specified to be
a range such that it falls outside an odd page's scope.
Create an instance of XSSFOddHeader from the supplied XML bean
@see XSSFSheet#GetOddHeader()
@param headerFooter
Get the content text representing this header
@return text
@author Yegor Kozlov
Represents a picture shape in a SpreadsheetML Drawing.
@author Yegor Kozlov
A default instance of CTShape used for creating new shapes.
This object specifies a picture object and all its properties
Construct a new XSSFPicture object. This constructor is called from
{@link XSSFDrawing#CreatePicture(XSSFClientAnchor, int)}
@param Drawing the XSSFDrawing that owns this picture
Returns a prototype that is used to construct new shapes
@return a prototype that is used to construct new shapes
Link this shape with the picture data
@param rel relationship referring the picture data
Return the underlying CT_Picture bean that holds all properties for this picture
@return the underlying CT_Picture bean
Reset the image to the original size.
Please note, that this method works correctly only for workbooks
with the default font size (Calibri 11pt for .xlsx).
If the default font is Changed the resized image can be streched vertically or horizontally.
Resize the image proportionally.
@see #resize(double, double)
Resize the image relatively to its current size.
Please note, that this method works correctly only for workbooks
with the default font size (Calibri 11pt for .xlsx).
If the default font is changed the resized image can be streched vertically or horizontally.
resize(1.0,1.0)
keeps the original size,
resize(0.5,0.5)
resize to 50% of the original,
resize(2.0,2.0)
resizes to 200% of the original.
resize({@link Double#MAX_VALUE},{@link Double#MAX_VALUE})
resizes to the dimension of the embedded image.
@param scaleX the amount by which the image width is multiplied relative to the original width,
when set to {@link java.lang.Double#MAX_VALUE} the width of the embedded image is used
@param scaleY the amount by which the image height is multiplied relative to the original height,
when set to {@link java.lang.Double#MAX_VALUE} the height of the embedded image is used
Calculate the preferred size for this picture.
@return XSSFClientAnchor with the preferred size for this image
Calculate the preferred size for this picture.
@param scale the amount by which image dimensions are multiplied relative to the original size.
@return XSSFClientAnchor with the preferred size for this image
Calculate the preferred size for this picture.
@param scaleX the amount by which image width is multiplied relative to the original width.
@param scaleY the amount by which image height is multiplied relative to the original height.
@return XSSFClientAnchor with the preferred size for this image
Return the dimension of this image
@param part the namespace part holding raw picture data
@param type type of the picture: {@link Workbook#PICTURE_TYPE_JPEG},
{@link Workbook#PICTURE_TYPE_PNG} or {@link Workbook#PICTURE_TYPE_DIB}
@return image dimension in pixels
Return the dimension of the embedded image in pixel
@return image dimension in pixels
@return the anchor that is used by this shape.
@return the sheet which contains the picture shape
Raw picture data, normally attached to a SpreadsheetML Drawing.
As a rule, pictures are stored in the /xl/media/ part of a SpreadsheetML package.
Relationships for each known picture type
Create a new XSSFPictureData node
@see NPOI.xssf.usermodel.XSSFWorkbook#AddPicture(byte[], int)
Construct XSSFPictureData from a namespace part
@param part the namespace part holding the Drawing data,
@param rel the namespace relationship holding this Drawing,
the relationship type must be http://schemas.Openxmlformats.org/officeDocument/2006/relationships/image
Suggests a file extension for this image.
@return the file extension.
Return an integer constant that specifies type of this picture
@return an integer constant that specifies type of this picture
@see NPOI.ss.usermodel.Workbook#PICTURE_TYPE_EMF
@see NPOI.ss.usermodel.Workbook#PICTURE_TYPE_WMF
@see NPOI.ss.usermodel.Workbook#PICTURE_TYPE_PICT
@see NPOI.ss.usermodel.Workbook#PICTURE_TYPE_JPEG
@see NPOI.ss.usermodel.Workbook#PICTURE_TYPE_PNG
@see NPOI.ss.usermodel.Workbook#PICTURE_TYPE_DIB
Gets the picture data as a byte array.
*PictureData objects store the actual content in the part directly without keeping a
copy like all others therefore we need to handle them differently.
Creates n XSSFPivotCache representing the given package part and relationship.
Should only be called when Reading in an existing file.
@param part - The package part that holds xml data representing this pivot cache defInition.
@param rel - the relationship of the given package part in the underlying OPC package
Creates an XSSFPivotCacheDefintion representing the given package part and relationship.
Should only be called when Reading in an existing file.
@param part - The package part that holds xml data representing this pivot cache defInition.
@param rel - the relationship of the given package part in the underlying OPC package
Find the 2D base data area for the pivot table, either from its direct reference or named table/range.
@return AreaReference representing the current area defined by the pivot table
@ if the ref1 attribute is not contiguous or the name attribute is not found.
Generates a cache field for each column in the reference area for the pivot table.
@param sheet The sheet where the data i collected from
Creates an XSSFPivotCacheRecords representing the given package part and relationship.
Should only be called when Reading in an existing file.
@param part - The package part that holds xml data representing this pivot cache records.
@param rel - the relationship of the given package part in the underlying OPC package
Creates an XSSFPivotTable representing the given package part and relationship.
Should only be called when Reading in an existing file.
@param part - The package part that holds xml data representing this pivot table.
@param rel - the relationship of the given package part in the underlying OPC package
Set default values for the table defInition.
Verify column index (relative to first column in1 pivot area) is within the
pivot area
@param columnIndex
@
Add a row label using data from the given column.
@param columnIndex the index of the column to be used as row label.
Add a column label using data from the given column and specified function
@param columnIndex the index of the column to be used as column label.
@param function the function to be used on the data
The following functions exists:
Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, Varp
@param valueFieldName the name of pivot table value field
Add a column label using data from the given column and specified function
@param columnIndex the index of the column to be used as column label.
@param function the function to be used on the data
The following functions exists:
Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, Varp
Add data field with data from the given column and specified function.
@param function the function to be used on the data
The following functions exists:
Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, Varp
@param columnIndex the index of the column to be used as column label.
@param valueFieldName the name of pivot table value field
Add column Containing data from the referenced area.
@param columnIndex the index of the column Containing the data
@param isDataField true if the data should be displayed in the pivot table.
Add filter for the column with the corresponding index and cell value
@param columnIndex index of column to filter on
Creates cacheSource and workSheetSource for pivot table and sets the source reference as well assets the location of the pivot table
@param sourceRef Source for data for pivot table - mutually exclusive with sourceName
@param sourceName Source for data for pivot table - mutually exclusive with sourceRef
@param position Position for pivot table in sheet
@param sourceSheet Sheet where the source will be collected from
Configure the name or area reference for the pivot table
@param wsSource CTWorksheetSource that needs the pivot source reference assignment
Page Setup and page margins Settings for the worksheet.
Set the paper size as enum value.
@param size value for the paper size.
Orientation of the page: landscape - portrait.
@return Orientation of the page
@see PrintOrientation
Get print page order.
@return PageOrder
Returns the paper size.
@return short - paper size
Returns the paper size as enum.
@return PaperSize paper size
@see PaperSize
Returns the scale.
@return short - scale
Set the page numbering start.
Page number for first printed page. If no value is specified, then 'automatic' is assumed.
@return page number for first printed page
Returns the number of pages wide to fit sheet in.
@return number of pages wide to fit sheet in
Returns the number of pages high to fit the sheet in.
@return number of pages high to fit the sheet in
Returns the left to right print order.
@return left to right print order
Returns the landscape mode.
@return landscape mode
Use the printer's defaults Settings for page Setup values and don't use the default values
specified in the schema. For example, if dpi is not present or specified in the XML, the
application shall not assume 600dpi as specified in the schema as a default and instead
shall let the printer specify the default dpi.
@return valid Settings
Returns the black and white Setting.
@return black and white Setting
Returns the draft mode.
@return draft mode
Returns the print notes.
@return print notes
Returns the no orientation.
@return no orientation
Returns the use page numbers.
@return use page numbers
Returns the horizontal resolution.
@return horizontal resolution
Returns the vertical resolution.
@return vertical resolution
Returns the header margin.
@return header margin
Returns the footer margin.
@return footer margin
Returns the number of copies.
@return number of copies
Defines namespaces, content types and normal file names / naming
patterns, for the well-known XSSF format parts.
A map to lookup POIXMLRelation by its relation type
JPG is an intentional duplicate of JPEG, to handle documents generated by other software. *
Fetches the InputStream to read the contents, based
of the specified core part, for which we are defined
as a suitable relationship
Get POIXMLRelation by relation type
@param rel relation type, for example,
http://schemas.openxmlformats.org/officeDocument/2006/relationships/image
@return registered POIXMLRelation or null if not found
Removes the relation from the internal table.
Following readings of files will ignoring the removed relation.
Relation to remove
Adds the relation to the internal table.
Following readings of files will process the given relation.
Relation to add
Rich text unicode string. These strings can have fonts applied to arbitary parts of the string.
Most strings in a workbook have formatting applied at the cell level, that is, the entire string in the cell has the
same formatting applied. In these cases, the formatting for the cell is stored in the styles part,
and the string for the cell can be shared across the workbook. The following code illustrates the example.
cell1.SetCellValue(new XSSFRichTextString("Apache POI"));
cell2.SetCellValue(new XSSFRichTextString("Apache POI"));
cell3.SetCellValue(new XSSFRichTextString("Apache POI"));
In the above example all three cells will use the same string cached on workbook level.
Some strings in the workbook may have formatting applied at a level that is more granular than the cell level.
For instance, specific characters within the string may be bolded, have coloring, italicizing, etc.
In these cases, the formatting is stored along with the text in the string table, and is treated as
a unique entry in the workbook. The following xml and code snippet illustrate this.
XSSFRichTextString s1 = new XSSFRichTextString("Apache POI");
s1.ApplyFont(boldArial);
cell1.SetCellValue(s1);
XSSFRichTextString s2 = new XSSFRichTextString("Apache POI");
s2.ApplyFont(italicCourier);
cell2.SetCellValue(s2);
@author Yegor Kozlov
Create a rich text string
Create empty rich text string and Initialize it with empty string
Create a rich text string from the supplied XML bean
Applies a font to the specified characters of a string.
@param startIndex The start index to apply the font to (inclusive)
@param endIndex The end index to apply the font to (exclusive)
@param fontIndex The font to use.
Applies a font to the specified characters of a string.
@param startIndex The start index to apply the font to (inclusive)
@param endIndex The end index to apply to font to (exclusive)
@param font The index of the font to use.
Sets the font of the entire string.
@param font The font to use.
Applies the specified font to the entire string.
@param fontIndex the font to Apply.
Append new text to this text run and apply the specify font to it
@param text the text to append
@param font the font to apply to the Appended text or null
if no formatting is required
Append new text to this text run
@param text the text to append
Copy font attributes from CTFont bean into CTRPrElt bean
Does this string have any explicit formatting applied, or is
it just text in the default style?
Removes any formatting that may have been applied to the string.
The index within the string to which the specified formatting run applies.
@param index the index of the formatting run
@return the index within the string.
Returns the number of characters this format run covers.
@param index the index of the formatting run
@return the number of characters this format run covers
Returns the plain string representation.
Returns the number of characters in this string.
@return The number of formatting Runs used.
Gets a copy of the font used in a particular formatting Run.
@param index the index of the formatting run
@return A copy of the font used or null if no formatting is applied to the specified text Run.
Return a copy of the font in use at a particular index.
@param index The index.
@return A copy of the font that's currently being applied at that
index or null if no font is being applied or the
index is out of range.
Return the underlying xml bean
CTRPrElt --> CTFont adapter
**
For all characters which cannot be represented in XML as defined by the XML 1.0 specification,
the characters are escaped using the Unicode numerical character representation escape character
format _xHHHH_, where H represents a hexadecimal character in the character's value.
Example: The Unicode character 0D is invalid in an XML 1.0 document,
so it shall be escaped as _x000D_
.
See section 3.18.9 in the OOXML spec.
@param value the string to decode
@return the decoded string
High level representation of a row of a spreadsheet.
the xml bean Containing all cell defInitions for this row
Cells of this row keyed by their column indexes.
The TreeMap ensures that the cells are ordered by columnIndex in the ascending order.
the parent sheet
Construct a XSSFRow.
@param row the xml bean Containing all cell defInitions for this row.
@param sheet the parent sheet.
Returns the XSSFSheet this row belongs to
@return the XSSFSheet that owns this row
Alias for {@link #cellIterator()} to allow foreach loops:
for(Cell cell : row){
...
}
@return an iterator over cells in this row.
Compares two XSSFRow
objects. Two rows are equal if they belong to the same worksheet and
their row indexes are equal.
@param row the XSSFRow
to be compared.
@return
-
the value
0
if the row number of this XSSFRow
is
equal to the row number of the argument XSSFRow
-
a value less than
0
if the row number of this this XSSFRow
is
numerically less than the row number of the argument XSSFRow
-
a value greater than
0
if the row number of this this XSSFRow
is
numerically greater than the row number of the argument XSSFRow
@throws IllegalArgumentException if the argument row belongs to a different worksheet
Returns the cell at the given (0 based) index,
with the {@link NPOI.SS.usermodel.Row.MissingCellPolicy} from the parent Workbook.
@return the cell at the given (0 based) index
Get the hssfcell representing a given column (logical cell)
0-based. If you ask for a cell that is not defined, then
you Get a null.
This is the basic call, with no policies applied
0 based column number
Cell representing that column or null if Undefined.
Get the number of the first cell Contained in this row.
@return short representing the first logical cell in the row,
or -1 if the row does not contain any cells.
Gets the index of the last cell Contained in this row PLUS ONE. The result also
happens to be the 1-based column number of the last cell. This value can be used as a
standard upper bound when iterating over cells:
short minColIx = row.GetFirstCellNum();
short maxColIx = row.GetLastCellNum();
for(short colIx=minColIx; colIx<maxColIx; colIx++) {
XSSFCell cell = row.GetCell(colIx);
if(cell == null) {
continue;
}
//... do something with cell
}
@return short representing the last logical cell in the row PLUS ONE,
or -1 if the row does not contain any cells.
Get the row's height measured in twips (1/20th of a point). If the height is not Set, the default worksheet value is returned,
See {@link NPOI.XSSF.usermodel.XSSFSheet#GetDefaultRowHeightInPoints()}
@return row height measured in twips (1/20th of a point)
Returns row height measured in point size. If the height is not Set, the default worksheet value is returned,
See {@link NPOI.XSSF.usermodel.XSSFSheet#GetDefaultRowHeightInPoints()}
@return row height measured in point size
@see NPOI.XSSF.usermodel.XSSFSheet#GetDefaultRowHeightInPoints()
Gets the number of defined cells (NOT number of cells in the actual row!).
That is to say if only columns 0,4,5 have values then there would be 3.
@return int representing the number of defined cells in the row.
Get row number this row represents
@return the row number (0 based)
Get whether or not to display this row with 0 height
@return - height is zero or not.
Is this row formatted? Most aren't, but some rows
do have whole-row styles. For those that do, you
can get the formatting from {@link #GetRowStyle()}
Returns the whole-row cell style. Most rows won't
have one of these, so will return null. Call
{@link #isFormatted()} to check first.
Applies a whole-row cell styling to the row.
If the value is null then the style information is Removed,
causing the cell to used the default workbook style.
Remove the Cell from this row.
@param cell the cell to remove
Returns the underlying CT_Row xml bean Containing all cell defInitions in this row
@return the underlying CT_Row xml bean
Fired when the document is written to an output stream.
@see NPOI.XSSF.usermodel.XSSFSheet#Write(java.io.OutputStream) ()
@return formatted xml representation of this row
update cell references when Shifting rows
@param n the number of rows to move
Copy the cells from srcRow to this row
If this row is not a blank row, this will merge the two rows, overwriting
the cells in this row with the cells in srcRow
If srcRow is null, overwrite cells in destination row with blank values, styles, etc per cell copy policy
srcRow may be from a different sheet in the same workbook
@param srcRow the rows to copy from
@param policy the policy to determine what gets copied
Represents a shape in a SpreadsheetML Drawing.
@author Yegor Kozlov
Parent Drawing
The parent shape, always not-null for shapes in groups
anchor that is used by this shape
Return the Drawing that owns this shape
@return the parent Drawing that owns this shape
Gets the parent shape.
@return the anchor that is used by this shape.
Returns xml bean with shape properties.
@return xml bean with shape properties.
Whether this shape is not Filled with a color
@return true if this shape is not Filled with a color.
Sets the color used to fill this shape using the solid fill pattern.
The color applied to the lines of this shape.
This object specifies a group shape that represents many shapes grouped together. This shape is to be treated
just as if it were a regular shape but instead of being described by a single geometry it is made up of all the
shape geometries encompassed within it. Within a group shape each of the shapes that make up the group are
specified just as they normally would.
@author Yegor Kozlov
Construct a new XSSFSimpleShape object.
@param Drawing the XSSFDrawing that owns this shape
@param ctGroup the XML bean that stores this group content
Initialize default structure of a new shape group
Constructs a textbox.
@param anchor the child anchor describes how this shape is attached
to the group.
@return the newly Created textbox.
Creates a simple shape. This includes such shapes as lines, rectangles,
and ovals.
@param anchor the child anchor describes how this shape is attached
to the group.
@return the newly Created shape.
Creates a simple shape. This includes such shapes as lines, rectangles,
and ovals.
@param anchor the child anchor describes how this shape is attached
to the group.
@return the newly Created shape.
Creates a picture.
@param anchor the client anchor describes how this picture is attached to the sheet.
@param pictureIndex the index of the picture in the workbook collection of pictures,
{@link XSSFWorkbook#getAllPictures()} .
@return the newly Created picture shape.
Sets the coordinate space of this group. All children are constrained
to these coordinates.
High level representation of a SpreadsheetML worksheet.
Sheets are the central structures within a workbook, and are where a user does most of his spreadsheet work.
The most common type of sheet is the worksheet, which is represented as a grid of cells. Worksheet cells can
contain text, numbers, dates, and formulas. Cells can also be formatted.
cache of master shared formulas in this sheet.
Master shared formula is the first formula in a group of shared formulas is saved in the f element.
Creates new XSSFSheet - called by XSSFWorkbook to create a sheet from scratch.
@see NPOI.XSSF.usermodel.XSSFWorkbook#CreateSheet()
Creates an XSSFSheet representing the given namespace part and relationship.
Should only be called by XSSFWorkbook when Reading in an exisiting file.
@param part - The namespace part that holds xml data represenring this sheet.
@param rel - the relationship of the given namespace part in the underlying OPC namespace
Returns the parent XSSFWorkbook
@return the parent XSSFWorkbook
Initialize worksheet data when Reading in an exisiting file.
Initialize worksheet data when creating a new sheet.
Read hyperlink relations, link them with CT_Hyperlink beans in this worksheet
and Initialize the internal array of XSSFHyperlink objects
Create a new CT_Worksheet instance with all values set to defaults
@return a new instance
Provide access to the CT_Worksheet bean holding this sheet's data
@return the CT_Worksheet bean holding this sheet's data
Returns the name of this sheet
@return the name of this sheet
Adds a merged region of cells on a sheet.
region to merge
index of this region
if region contains fewer than 2 cells
if region intersects with an existing merged region
or multi-cell array formula on this sheet
Adds a merged region of cells (hence those cells form one).
Skips validation.It is possible to create overlapping merged regions
or create a merged region that intersects a multi-cell array formula
with this formula, which may result in a corrupt workbook.
region to merge
index of this region
if region contains fewer than 2 cells
Adds a merged region of cells (hence those cells form one).
region (rowfrom/colfrom-rowto/colto) to merge
whether to validate merged region
index of this region
if region intersects with a multi-cell array formula or
if region intersects with an existing region on this sheet
if region contains fewer than 2 cells
Verify that the candidate region does not intersect with an existing multi-cell array formula in this sheet
@param region
@throws InvalidOperationException if candidate region intersects an existing array formula in this sheet
Verify that none of the merged regions intersect a multi-cell array formula in this sheet
@param region
@throws InvalidOperationException if candidate region intersects an existing array formula in this sheet
Verify that candidate region does not intersect with an existing merged region in this sheet
@param candidateRegion
@throws InvalidOperationException if candidate region intersects an existing merged region in this sheet
Verify that no merged regions intersect another merged region in this sheet.
@throws InvalidOperationException if at least one region intersects with another merged region in this sheet
Verify that merged regions do not intersect multi-cell array formulas and
no merged regions intersect another merged region in this sheet.
@throws InvalidOperationException if region intersects with a multi-cell array formula
@throws InvalidOperationException if at least one region intersects with another merged region in this sheet
Adjusts the column width to fit the contents.
This process can be relatively slow on large sheets, so this should
normally only be called once per column, at the end of your
Processing.
@param column the column index
Adjusts the column width to fit the contents.
This process can be relatively slow on large sheets, so this should
normally only be called once per column, at the end of your
Processing.
You can specify whether the content of merged cells should be considered or ignored.
Default is to ignore merged cells.
@param column the column index
@param useMergedCells whether to use the contents of merged cells when calculating the width of the column
Return the sheet's existing Drawing, or null if there isn't yet one.
Use {@link #CreateDrawingPatriarch()} to Get or create
@return a SpreadsheetML Drawing
Create a new SpreadsheetML Drawing. If this sheet already Contains a Drawing - return that.
@return a SpreadsheetML Drawing
Get VML drawing for this sheet (aka 'legacy' drawig)
@param autoCreate if true, then a new VML drawing part is Created
@return the VML drawing of null
if the drawing was not found and autoCreate=false
Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
@param colSplit Horizonatal position of split.
@param rowSplit Vertical position of split.
Creates a split (freezepane). Any existing freezepane or split pane is overwritten.
If both colSplit and rowSplit are zero then the existing freeze pane is Removed
@param colSplit Horizonatal position of split.
@param rowSplit Vertical position of split.
@param leftmostColumn Left column visible in right pane.
@param topRow Top row visible in bottom pane
Create a new row within the sheet and return the high level representation
@param rownum row number
@return High level {@link XSSFRow} object representing a row in the sheet
@see #RemoveRow(NPOI.SS.usermodel.Row)
Creates a split pane. Any existing freezepane or split pane is overwritten.
@param xSplitPos Horizonatal position of split (in 1/20th of a point).
@param ySplitPos Vertical position of split (in 1/20th of a point).
@param topRow Top row visible in bottom pane
@param leftmostColumn Left column visible in right pane.
@param activePane Active pane. One of: PANE_LOWER_RIGHT,
PANE_UPPER_RIGHT, PANE_LOWER_LEFT, PANE_UPPER_LEFT
@see NPOI.SS.usermodel.Sheet#PANE_LOWER_LEFT
@see NPOI.SS.usermodel.Sheet#PANE_LOWER_RIGHT
@see NPOI.SS.usermodel.Sheet#PANE_UPPER_LEFT
@see NPOI.SS.usermodel.Sheet#PANE_UPPER_RIGHT
Returns cell comment for the specified row and column
The row.
The column.
cell comment or null
if not found
Returns cell comment for the specified location
cell location
return cell comment or null if not found
Returns all cell comments on this sheet.
return A Dictionary of each Comment in the sheet, keyed on the cell address where the comment is located.
Get a Hyperlink in this sheet anchored at row, column
return hyperlink if there is a hyperlink anchored at row, column; otherwise returns null
Get a Hyperlink in this sheet located in a cell specified by {code addr}
The address of the cell containing the hyperlink
return hyperlink if there is a hyperlink anchored at {@code addr}; otherwise returns {@code null}
Get a list of Hyperlinks in this sheet
Vertical page break information used for print layout view, page layout view, drawing print breaks
in normal view, and for printing the worksheet.
@return column indexes of all the vertical page breaks, never null
Get the actual column width (in units of 1/256th of a character width )
Note, the returned value is always gerater that {@link #GetDefaultColumnWidth()} because the latter does not include margins.
Actual column width measured as the number of characters of the maximum digit width of the
numbers 0, 1, 2, ..., 9 as rendered in the normal style's font. There are 4 pixels of margin
pAdding (two on each side), plus 1 pixel pAdding for the gridlines.
@param columnIndex - the column to set (0-based)
@return width - the width in units of 1/256th of a character width
Get the actual column width in pixels
Please note, that this method works correctly only for workbooks
with the default font size (Calibri 11pt for .xlsx).
Get the default column width for the sheet (if the columns do not define their own width) in
characters.
Note, this value is different from {@link #GetColumnWidth(int)}. The latter is always greater and includes
4 pixels of margin pAdding (two on each side), plus 1 pixel pAdding for the gridlines.
@return column width, default value is 8
Get the default row height for the sheet (if the rows do not define their own height) in
twips (1/20 of a point)
@return default row height
Get the default row height for the sheet measued in point size (if the rows do not define their own height).
@return default row height in points
Returns the CellStyle that applies to the given
(0 based) column, or null if no style has been
set for that column
Whether the text is displayed in right-to-left mode in the window
@return whether the text is displayed in right-to-left mode in the window
Get whether to display the guts or not,
default value is true
@return bool - guts or no guts
Gets the flag indicating whether the window should show 0 (zero) in cells Containing zero value.
When false, cells with zero value appear blank instead of Showing the number zero.
@return whether all zero values on the worksheet are displayed
Gets the first row on the sheet
@return the number of the first logical row on the sheet, zero based
Flag indicating whether the Fit to Page print option is enabled.
@return true
Returns the default footer for the sheet,
creating one as needed.
You may also want to look at
{@link #GetFirstFooter()},
{@link #GetOddFooter()} and
{@link #GetEvenFooter()}
Returns the default header for the sheet,
creating one as needed.
You may also want to look at
{@link #GetFirstHeader()},
{@link #GetOddHeader()} and
{@link #GetEvenHeader()}
Returns the odd footer. Used on all pages unless
other footers also present, when used on only
odd pages.
Returns the even footer. Not there by default, but
when Set, used on even pages.
Returns the first page footer. Not there by
default, but when Set, used on the first page.
Returns the odd header. Used on all pages unless
other headers also present, when used on only
odd pages.
Returns the even header. Not there by default, but
when Set, used on even pages.
Returns the first page header. Not there by
default, but when Set, used on the first page.
Determine whether printed output for this sheet will be horizontally centered.
Gets the size of the margin in inches.
@param margin which margin to get
@return the size of the margin
@see Sheet#LeftMargin
@see Sheet#RightMargin
@see Sheet#TopMargin
@see Sheet#BottomMargin
@see Sheet#HeaderMargin
@see Sheet#FooterMargin
Sets the size of the margin in inches.
@param margin which margin to get
@param size the size of the margin
@see Sheet#LeftMargin
@see Sheet#RightMargin
@see Sheet#TopMargin
@see Sheet#BottomMargin
@see Sheet#HeaderMargin
@see Sheet#FooterMargin
@return the merged region at the specified index
@throws InvalidOperationException if this worksheet does not contain merged regions
Returns the list of merged regions. If you want multiple regions, this is
faster than calling {@link #getMergedRegion(int)} each time.
@return the list of merged regions
@throws InvalidOperationException if this worksheet does not contain merged regions
Returns the number of merged regions defined in this worksheet
@return number of merged regions in this worksheet
Returns the information regarding the currently configured pane (split or freeze).
@return null if no pane configured, or the pane information.
Returns the number of phsyically defined rows (NOT the number of rows in the sheet)
@return the number of phsyically defined rows
Gets the print Setup object.
@return The user model for the print Setup object.
Answer whether protection is enabled or disabled
@return true => protection enabled; false => protection disabled
Enables sheet protection and Sets the password for the sheet.
Also Sets some attributes on the {@link CT_SheetProtection} that correspond to
the default values used by Excel
@param password to set for protection. Pass null
to remove protection
Sets the sheet password.
@param password if null, the password will be removed
@param hashAlgo if null, the password will be set as XOR password (Excel 2010 and earlier)
otherwise the given algorithm is used for calculating the hash password (Excel 2013)
Validate the password against the stored hash, the hashing method will be determined
by the existing password attributes
@return true, if the hashes match (... though original password may differ ...)
Returns the logical row ( 0-based). If you ask for a row that is not
defined you get a null. This is to say row 4 represents the fifth row on a sheet.
@param rownum row to get
@return XSSFRow
representing the rownumber or null
if its not defined on the sheet
returns all rows between startRow and endRow, inclusive.
Rows between startRow and endRow that haven't been created are not included
in result unless createRowIfMissing is true
@param startRow the first row number in this sheet to return
@param endRow the last row number in this sheet to return
@param createRowIfMissing
@return
@throws IllegalArgumentException if startRowNum and endRowNum are not in ascending order
Horizontal page break information used for print layout view, page layout view, drawing print breaks in normal
view, and for printing the worksheet.
@return row indexes of all the horizontal page breaks, never null
Flag indicating whether summary rows appear below detail in an outline, when Applying an outline.
When true a summary row is inserted below the detailed data being summarized and a
new outline level is established on that row.
When false a summary row is inserted above the detailed data being summarized and a new outline level
is established on that row.
@return true
if row summaries appear below detail in the outline
Flag indicating whether summary columns appear to the right of detail in an outline, when Applying an outline.
When true a summary column is inserted to the right of the detailed data being summarized
and a new outline level is established on that column.
When false a summary column is inserted to the left of the detailed data being
summarized and a new outline level is established on that column.
@return true
if col summaries appear right of the detail in the outline
Ensure CT_Worksheet.CT_SheetPr.CT_OutlinePr
A flag indicating whether scenarios are locked when the sheet is protected.
The top row in the visible view when the sheet is first viewed after opening it in a viewer
Determine whether printed output for this sheet will be vertically centered.
@return whether printed output for this sheet will be vertically centered.
Group between (0 based) columns
Do not leave the width attribute undefined (see #52186).
Tie a range of cell toGether so that they can be collapsed or expanded
@param fromRow start row (0-based)
@param toRow end row (0-based)
Determines if there is a page break at the indicated column
Get the hidden state for a given column.
@param columnIndex - the column to set (0-based)
@return hidden - false
if the column is visible
Gets the flag indicating whether this sheet should display formulas.
@return true
if this sheet should display formulas.
Gets the flag indicating whether this sheet displays the lines
between rows and columns to make editing and Reading easier.
@return true
if this sheet displays gridlines.
@see #isPrintGridlines() to check if printing of gridlines is turned on or off
Gets the flag indicating whether this sheet should display row and column headings.
Row heading are the row numbers to the side of the sheet
Column heading are the letters or numbers that appear above the columns of the sheet
@return true
if this sheet should display row and column headings.
Returns whether gridlines are printed.
@return whether gridlines are printed
Returns whether row and column headings are printed.
@return whether row and column headings are printed
Tests if there is a page break at the indicated row
@param row index of the row to test
@return true
if there is a page break at the indicated row
Sets a page break at the indicated row
Breaks occur above the specified row and left of the specified column inclusive.
For example, sheet.SetColumnBreak(2);
breaks the sheet into two parts
with columns A,B,C in the first and D,E,... in the second. Simuilar, sheet.SetRowBreak(2);
breaks the sheet into two parts with first three rows (rownum=1...3) in the first part
and rows starting with rownum=4 in the second.
@param row the row to break, inclusive
Removes a page break at the indicated column
Removes a merged region of cells (hence letting them free)
@param index of the region to unmerge
Removes a number of merged regions of cells (hence letting them free)
This method can be used to bulk-remove merged regions in a way
much faster than calling RemoveMergedRegion() for every single
merged region.
@param indices A Set of the regions to unmerge
Remove a row from this sheet. All cells Contained in the row are Removed as well
@param row the row to Remove.
Removes the page break at the indicated row
Whether Excel will be asked to recalculate all formulas when the
workbook is opened.
Flag indicating whether the sheet displays Automatic Page Breaks.
@return true
if the sheet displays Automatic Page Breaks.
Sets a page break at the indicated column.
Breaks occur above the specified row and left of the specified column inclusive.
For example, sheet.SetColumnBreak(2);
breaks the sheet into two parts
with columns A,B,C in the first and D,E,... in the second. Simuilar, sheet.SetRowBreak(2);
breaks the sheet into two parts with first three rows (rownum=1...3) in the first part
and rows starting with rownum=4 in the second.
@param column the column to break, inclusive
Sets all adjacent columns of the same outline level to the specified
hidden status.
@param pIdx
the col info index of the start of the outline group
@return the column index of the last column in the outline group
'Collapsed' state is stored in a single column col info record
immediately after the outline group
@param idx
@return a bool represented if the column is collapsed
Get the visibility state for a given column.
@param columnIndex - the column to get (0-based)
@param hidden - the visiblity state of the column
* Set the width (in units of 1/256th of a character width)
*
*
* The maximum column width for an individual cell is 255 characters.
* This value represents the number of characters that can be displayed
* in a cell that is formatted with the standard font (first font in the workbook).
*
*
*
* Character width is defined as the maximum digit width
* of the numbers 0, 1, 2, ... 9
as rendered
* using the default font (first font in the workbook).
*
* Unless you are using a very special font, the default character is '0' (zero),
* this is true for Arial (default font font in HSSF) and Calibri (default font in XSSF)
*
*
*
* Please note, that the width set by this method includes 4 pixels of margin pAdding (two on each side),
* plus 1 pixel pAdding for the gridlines (Section 3.3.1.12 of the OOXML spec).
* This results is a slightly less value of visible characters than passed to this method (approx. 1/2 of a character).
*
*
* To compute the actual number of visible characters,
* Excel uses the following formula (Section 3.3.1.12 of the OOXML spec):
*
*
* width = TRuncate([{Number of Visible Characters} *
* {Maximum Digit Width} + {5 pixel pAdding}]/{Maximum Digit Width}*256)/256
*
* Using the Calibri font as an example, the maximum digit width of 11 point font size is 7 pixels (at 96 dpi).
* If you set a column width to be eight characters wide, e.g. SetColumnWidth(columnIndex, 8*256)
,
* then the actual value of visible characters (the value Shown in Excel) is derived from the following equation:
*
TRuncate([numChars*7+5]/7*256)/256 = 8;
*
*
* which gives 7.29
.
*
* @param columnIndex - the column to set (0-based)
* @param width - the width in units of 1/256th of a character width
* @throws ArgumentException if width > 255*256 (the maximum column width in Excel is 255 characters)
group the row It is possible for collapsed to be false and yet still have
the rows in question hidden. This can be achieved by having a lower
outline level collapsed, thus hiding all the child rows. Note that in
this case, if the lowest level were expanded, the middle level would
remain collapsed.
@param rowIndex -
the row involved, 0 based
@param collapse -
bool value for collapse
@param rowIndex the zero based row index to collapse
@param rowIndex the zero based row index to find from
@param rowNumber the zero based row index to expand
@param row the zero based row index to find from
@param row the zero based row index to find from
@param row the zero based row index to find from
Sets the zoom magnification for the sheet. The zoom is expressed as a
fraction. For example to express a zoom of 75% use 3 for the numerator
and 4 for the denominator.
@param numerator The numerator for the zoom magnification.
@param denominator The denominator for the zoom magnification.
@see #SetZoom(int)
Window zoom magnification for current view representing percent values.
Valid values range from 10 to 400. Horizontal & Vertical scale toGether.
For example:
10 - 10%
20 - 20%
...
100 - 100%
...
400 - 400%
Current view can be Normal, Page Layout, or Page Break Preview.
@param scale window zoom magnification
@throws ArgumentException if scale is invalid
copyRows rows from srcRows to this sheet starting at destStartRow
Additionally copies merged regions that are completely defined in these
rows (ie. merged 2 cells on a row to be shifted).
@param srcRows the rows to copy. Formulas will be offset by the difference
in the row number of the first row in srcRows and destStartRow (even if srcRows
are from a different sheet).
@param destStartRow the row in this sheet to paste the first row of srcRows
the remainder of srcRows will be pasted below destStartRow per the cell copy policy
@param policy is the cell copy policy, which can be used to merge the source and destination
when the source is blank, copy styles only, paste as value, etc
Copies rows between srcStartRow and srcEndRow to the same sheet, starting at destStartRow
Convenience function for {@link #copyRows(List, int, CellCopyPolicy)}
Equivalent to copyRows(getRows(srcStartRow, srcEndRow, false), destStartRow, cellCopyPolicy)
@param srcStartRow the index of the first row to copy the cells from in this sheet
@param srcEndRow the index of the last row to copy the cells from in this sheet
@param destStartRow the index of the first row to copy the cells to in this sheet
@param cellCopyPolicy the policy to use to determine how cells are copied
Shifts rows between startRow and endRow n number of rows.
If you use a negative number, it will shift rows up.
Code ensures that rows don't wrap around.
Calls ShiftRows(startRow, endRow, n, false, false);
Additionally Shifts merged regions that are completely defined in these
rows (ie. merged 2 cells on a row to be Shifted).
@param startRow the row to start Shifting
@param endRow the row to end Shifting
@param n the number of rows to shift
Shifts rows between startRow and endRow n number of rows.
If you use a negative number, it will shift rows up.
Code ensures that rows don't wrap around
Additionally Shifts merged regions that are completely defined in these
rows (ie. merged 2 cells on a row to be Shifted).
@param startRow the row to start Shifting
@param endRow the row to end Shifting
@param n the number of rows to shift
@param copyRowHeight whether to copy the row height during the shift
@param reSetOriginalRowHeight whether to set the original row's height to the default
Ungroup a range of rows that were previously groupped
@param fromRow start row (0-based)
@param toRow end row (0-based)
Returns a flag indicating whether this sheet is selected.
When only 1 sheet is selected and active, this value should be in synch with the activeTab value.
In case of a conflict, the Start Part Setting wins and Sets the active sheet tab.
Note: multiple sheets can be selected, but only one sheet can be active at one time.
@return true
if this sheet is selected
Register a hyperlink in the collection of hyperlinks on this sheet
@param hyperlink the link to add
Removes a hyperlink in the collection of hyperlinks on this sheet
@param row row index
@param column column index
Return location of the active cell, e.g. A1
.
@return the location of the active cell.
Does this sheet have any comments on it? We need to know,
so we can decide about writing it to disk or not
Return the default sheet view. This is the last one if the sheet's views, according to sec. 3.3.1.83
of the OOXML spec: "A single sheet view defInition. When more than 1 sheet view is defined in the file,
it means that when opening the workbook, each sheet view corresponds to a separate window within the
spreadsheet application, where each window is Showing the particular sheet. Containing the same
workbookViewId value, the last sheetView defInition is loaded, and the others are discarded.
When multiple windows are viewing the same sheet, multiple sheetView elements (with corresponding
workbookView entries) are saved."
Returns the sheet's comments object if there is one,
or null if not
@param create create a new comments table if it does not exist
Return a master shared formula by index
@param sid shared group index
@return a CT_CellFormula bean holding shared formula or null
if not found
@return true when Autofilters are locked and the sheet is protected.
@return true when Deleting columns is locked and the sheet is protected.
@return true when Deleting rows is locked and the sheet is protected.
@return true when Formatting cells is locked and the sheet is protected.
@return true when Formatting columns is locked and the sheet is protected.
@return true when Formatting rows is locked and the sheet is protected.
@return true when Inserting columns is locked and the sheet is protected.
@return true when Inserting hyperlinks is locked and the sheet is protected.
@return true when Inserting rows is locked and the sheet is protected.
@return true when Pivot tables are locked and the sheet is protected.
@return true when Sorting is locked and the sheet is protected.
@return true when Objects are locked and the sheet is protected.
@return true when Scenarios are locked and the sheet is protected.
@return true when Selection of locked cells is locked and the sheet is protected.
@return true when Selection of unlocked cells is locked and the sheet is protected.
@return true when Sheet is Protected.
Enable sheet protection
Disable sheet protection
Enable or disable Autofilters locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Deleting columns locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Deleting rows locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Formatting cells locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Formatting columns locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Formatting rows locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Inserting columns locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Inserting hyperlinks locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Inserting rows locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Pivot Tables locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Sort locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Objects locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Scenarios locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Selection of locked cells locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Enable or disable Selection of unlocked cells locking.
This does not modify sheet protection status.
To enforce this un-/locking, call {@link #disableLocking()} or {@link #enableLocking()}
Also Creates cells if they don't exist
Creates a new Table, and associates it with this Sheet
Returns any tables associated with this Sheet
Set background color of the sheet tab
@param colorIndex the indexed color to set, must be a constant from {@link IndexedColors}
Get or set background color of the sheet tab.
The value is null if no sheet tab color is set.
Creates an empty XSSFPivotTable and Sets up all its relationships
including: pivotCacheDefInition, pivotCacheRecords
@return returns a pivotTable
Create a pivot table using the AreaReference range on sourceSheet, at the given position.
If the source reference contains a sheet name, it must match the sourceSheet
@param source location of pivot data
@param position A reference to the top left cell where the pivot table will start
@param sourceSheet The sheet containing the source data, if the source reference doesn't contain a sheet name
@throws IllegalArgumentException if source references a sheet different than sourceSheet
@return The pivot table
Create a pivot table using the AreaReference or named/table range on sourceSheet, at the given position.
If the source reference contains a sheet name, it must match the sourceSheet.
@param sourceRef location of pivot data - mutually exclusive with SourceName
@param sourceName range or table name for pivot data - mutually exclusive with SourceRef
@param position A reference to the top left cell where the pivot table will start
@param sourceSheet The sheet containing the source data, if the source reference doesn't contain a sheet name
@throws IllegalArgumentException if source references a sheet different than sourceSheet
@return The pivot table
Create a pivot table using the AreaReference range, at the given position.
If the source reference contains a sheet name, that sheet is used, otherwise this sheet is assumed as the source sheet.
@param source location of pivot data
@param position A reference to the top left cell where the pivot table will start
@return The pivot table
Create a pivot table using the Name range reference on sourceSheet, at the given position.
If the source reference contains a sheet name, it must match the sourceSheet
@param source location of pivot data
@param position A reference to the top left cell where the pivot table will start
@param sourceSheet The sheet containing the source data, if the source reference doesn't contain a sheet name
@ if source references a sheet different than sourceSheet
@return The pivot table
Create a pivot table using the Name range, at the given position.
If the source reference contains a sheet name, that sheet is used, otherwise this sheet is assumed as the source sheet.
@param source location of pivot data
@param position A reference to the top left cell where the pivot table will start
@return The pivot table
Create a pivot table using the Table, at the given position.
Tables are required to have a sheet reference, so no additional logic around reference sheet is needed.
@param source location of pivot data
@param position A reference to the top left cell where the pivot table will start
@return The pivot table
Returns all the pivot tables for this Sheet
Add ignored errors (usually to suppress them in the UI of a consuming
application).
@param cell Cell.
@param ignoredErrorTypes Types of error to ignore there.
Ignore errors across a range of cells.
@param region Range of cells.
@param ignoredErrorTypes Types of error to ignore there.
Returns the errors currently being ignored and the ranges
where they are ignored.
@return Map of error type to the range(s) where they are ignored.
XSSF Conditional Formattings
Office 2010 Conditional Formatting extensions namespace
A factory method allowing to create a conditional formatting rule
with a cell comparison operator
TODO - formulas Containing cell references are currently not Parsed properly
@param comparisonOperation - a constant value from
{@link NPOI.hssf.record.CFRuleRecord.ComparisonOperator}:
- BETWEEN
- NOT_BETWEEN
- EQUAL
- NOT_EQUAL
- GT
- LT
- GE
- LE
@param formula1 - formula for the valued, Compared with the cell
@param formula2 - second formula (only used with
{@link NPOI.ss.usermodel.ComparisonOperator#BETWEEN}) and
{@link NPOI.ss.usermodel.ComparisonOperator#NOT_BETWEEN} operations)
A factory method allowing the creation of conditional formatting
rules using an Icon Set / Multi-State formatting.
The thresholds for it will be created, but will be empty
and require configuring with
{@link XSSFConditionalFormattingRule#getMultiStateFormatting()}
then
{@link XSSFIconMultiStateFormatting#getThresholds()}
Gets Conditional Formatting object at a particular index
@param index
of the Conditional Formatting object to fetch
@return Conditional Formatting object
@return number of Conditional Formatting objects of the sheet
Removes a Conditional Formatting object by index
@param index of a Conditional Formatting object to remove
Represents a shape with a predefined geometry in a SpreadsheetML Drawing.
Possible shape types are defined in {@link NPOI.SS.UserModel.ShapeTypes}
List of the paragraphs that make up the text in this shape
A default instance of CTShape used for creating new shapes.
Xml bean that stores properties of this shape
Prototype with the default structure of a new auto-shape.
Returns the text from all paragraphs in the shape. Paragraphs are Separated by new lines.
@return text Contained within this shape or empty string
Returns a string Containing an appropriate prefix for an auto-numbering bullet
@param scheme the auto-numbering scheme used by the bullet
@param value the value of the bullet
@return appropriate prefix for an auto-numbering bullet
Convert an integer to its alpha equivalent e.g. 1 = A, 2 = B, 27 = AA etc
Convert an integer to its roman equivalent e.g. 1 = I, 9 = IX etc
Clear all text from this shape
Set a single paragraph of text on the shape. Note this will replace all existing paragraphs Created on the shape.
@param text string representing the paragraph text
Set a single paragraph of text on the shape. Note this will replace all existing paragraphs Created on the shape.
@param str rich text string representing the paragraph text
Returns a collection of the XSSFTextParagraphs that are attached to this shape
@return text paragraphs in this shape
Add a new paragraph run to this shape
@return Created paragraph run
Add a new paragraph run to this shape, Set to the provided string
@return Created paragraph run
Add a new paragraph run to this shape, Set to the provided rich text string
@return Created paragraph run
Returns the type of horizontal overflow for the text.
@return the type of horizontal overflow
Returns the type of vertical overflow for the text.
@return the type of vertical overflow
Returns the type of vertical alignment for the text within the shape.
@return the type of vertical alignment
Gets the vertical orientation of the text
@return vertical orientation of the text
Returns the distance (in points) between the bottom of the text frame
and the bottom of the inscribed rectangle of the shape that Contains the text.
@return the bottom inset in points
Returns the distance (in points) between the left edge of the text frame
and the left edge of the inscribed rectangle of the shape that Contains
the text.
@return the left inset in points
Returns the distance (in points) between the right edge of the
text frame and the right edge of the inscribed rectangle of the shape
that Contains the text.
@return the right inset in points
Returns the distance (in points) between the top of the text frame
and the top of the inscribed rectangle of the shape that Contains the text.
@return the top inset in points
@return whether to wrap words within the bounding rectangle
Specifies that a shape should be auto-fit to fully contain the text described within it.
Auto-fitting is when text within a shape is scaled in order to contain all the text inside
@param value type of autofit
@return type of autofit
Gets the shape type, one of the constants defined in {@link NPOI.SS.UserModel.ShapeTypes}.
@return the shape type
@see NPOI.SS.UserModel.ShapeTypes
org.Openxmlformats.schemas.spreadsheetml.x2006.main.CTRPrElt to
org.Openxmlformats.schemas.Drawingml.x2006.main.CTFont adapter
This class : the Table Part (Open Office XML Part 4:
chapter 3.5.1)
This implementation works under the assumption that a table Contains mappings to a subtree of an XML.
The root element of this subtree an occur multiple times (one for each row of the table). The child nodes
of the root element can be only attributes or element with maxOccurs=1 property set
@author Roberto Manicardi
Checks if this Table element Contains even a single mapping to the map identified by id
@param id the XSSFMap ID
@return true if the Table element contain mappings
Calculates the xpath of the root element for the table. This will be the common part
of all the mapping's xpaths
@return the xpath of the table's root element
Note this list is static - once read, it does not notice later changes to the underlying column structures
@return List of XSSFXmlColumnPr
@return the name of the Table, if set
@return the display name of the Table, if set
@return the number of mapped table columns (see Open Office XML Part 4: chapter 3.5.1.4)
@return The reference for the cell in the top-left part of the table
(see Open Office XML Part 4: chapter 3.5.1.2, attribute ref)
To synchronize with changes to the underlying CTTable,
call {@link #updateReferences()}.
@return The reference for the cell in the bottom-right part of the table
(see Open Office XML Part 4: chapter 3.5.1.2, attribute ref)
Does not track updates to underlying changes to CTTable
To synchronize with changes to the underlying CTTable,
call {@link #updateReferences()}.
@since POI 3.15 beta 3
Clears the cached values set by {@link #getStartCellReference()}
and {@link #getEndCellReference()}.
The next call to {@link #getStartCellReference()} and
{@link #getEndCellReference()} will synchronize the
cell references with the underlying CTTable
.
Thus, {@link #updateReferences()} is inexpensive.
@since POI 3.15 beta 3
@return the total number of rows in the selection. (Note: in this version autofiltering is ignored)
Returns 0 if the start or end cell references are not set.
To synchronize with changes to the underlying CTTable,
call {@link #updateReferences()}.
Synchronize table headers with cell values in the parent sheet.
Headers must be in sync, otherwise Excel will display a
"Found unreadable content" message on startup.
If calling both {@link #updateReferences()} and
{@link #updateHeaders()}, {@link #updateReferences()}
should be called first.
Gets the relative column index of a column in this table having the header name column
.
The column index is relative to the left-most column in the table, 0-indexed.
Returns -1
if column
is not a header name in table.
Column Header names are case-insensitive
Note: this function caches column names for performance. To flush the cache (because columns
have been moved or column headers have been changed), {@link #updateHeaders()} must be called.
@since 3.15 beta 2
Represents a text box in a SpreadsheetML Drawing.
@author Yegor Kozlov
Represents a paragraph of text within the Containing text body.
The paragraph is the highest level text separation mechanism.
Add a new run of text
@return a new run of text
Insert a line break
@return text run representing this line break ('\n')
get or set the alignment that is to be applied to the paragraph.
Possible values for this include left, right, centered, justified and distributed,
If this attribute is omitted, then a value of left is implied.
@return alignment that is applied to the paragraph
Determines where vertically on a line of text the actual words are positioned. This deals
with vertical placement of the characters with respect to the baselines. For instance
having text anchored to the top baseline, anchored to the bottom baseline, centered in
between, etc.
If this attribute is omitted, then a value of baseline is implied.
@return alignment that is applied to the paragraph
@return the font to be used on bullet characters within a given paragraph
@return the character to be used in place of the standard bullet point
@return the color of bullet characters within a given paragraph.
A null
value means to use the text font color.
@return the indent applied to the first line of text in the paragraph.
Specifies the left margin of the paragraph. This is specified in Addition to the text body
inset and applies only to this text paragraph. That is the text body inset and the LeftMargin
attributes are Additive with respect to the text position.
@param value the left margin of the paragraph, -1 to clear the margin and use the default of 0.
Specifies the right margin of the paragraph. This is specified in Addition to the text body
inset and applies only to this text paragraph. That is the text body inset and the marR
attributes are Additive with respect to the text position.
@param value the right margin of the paragraph, -1 to clear the margin and use the default of 0.
@return the default size for a tab character within this paragraph in points
Add a single tab stop to be used on a line of text when there are one or more tab characters
present within the text.
@param value the position of the tab stop relative to the left margin
Specifies the particular level text properties that this paragraph will follow.
The value for this attribute formats the text according to the corresponding level
paragraph properties defined in the list of styles associated with the body of text
that this paragraph belongs to (therefore in the parent shape).
Note that the closest properties object to the text is used, therefore if there is
a conflict between the text paragraph properties and the list style properties for
this level then the text paragraph properties will take precedence.
Returns the level of text properties that this paragraph will follow.
@return the text level of this paragraph (0-based). Default is 0.
Returns whether this paragraph has bullets
Set or unset this paragraph as a bullet point
@param flag whether text in this paragraph has bullets
Set this paragraph as an automatic numbered bullet point
@param scheme type of auto-numbering
@param startAt the number that will start number for a given sequence of automatically
numbered bullets (1-based).
Set this paragraph as an automatic numbered bullet point
@param scheme type of auto-numbering
Returns whether this paragraph has automatic numbered bullets
Returns the starting number if this paragraph has automatic numbered bullets, otherwise returns 0
Returns the auto number scheme if this paragraph has automatic numbered bullets, otherwise returns ListAutoNumber.ARABIC_PLAIN
Represents a run of text within the Containing text body. The run element is the
lowest level text separation mechanism within a text body.
@return font size in points or -1 if font size is not Set.
@return the spacing between characters within a text Run,
If this attribute is omitted then a value of 0 or no adjustment is assumed.
Specifies the typeface, or name of the font that is to be used for this text Run.
@param typeface the font to apply to this text Run.
The value of null
unsets the Typeface attribute from the underlying xml.
@return font family or null if not Set
get or set whether a run of text will be formatted as strikethrough text. Default is false.
get or set whether a run of text will be formatted as a superscript text. Default is false.
Default base line offset is 30%
Set the baseline for both the superscript and subscript fonts.
The size is specified using a percentage.
Positive values indicate superscript, negative values indicate subscript.
@param baselineOffset
get or set whether a run of text will be formatted as a superscript text. Default is false.
Default base line offset is -25%.
@return whether a run of text will be formatted as a superscript text. Default is false.
get or set whether this run of text is formatted as bold text
get or set whether this run of text is formatted as italic text
get or set whether this run of text is formatted as underlined text
Create a new XSSFVBAPart node
Construct XSSFVBAPart from a package part
@param part the package part holding the VBA data,
@param rel the package relationship holding this part
Like *PictureData, VBA objects store the actual content in the part
directly without keeping a copy like all others therefore we need to
handle them differently.
Represents a SpreadsheetML VML Drawing.
In Excel 2007 VML Drawings are used to describe properties of cell comments,
although the spec says that VML is deprecated:
The VML format is a legacy format originally introduced with Office 2000 and is included and fully defined
in this Standard for backwards compatibility reasons. The DrawingML format is a newer and richer format
Created with the goal of eventually replacing any uses of VML in the Office Open XML formats. VML should be
considered a deprecated format included in Office Open XML for legacy reasons only and new applications that
need a file format for Drawings are strongly encouraged to use preferentially DrawingML
Warning - Excel is known to Put invalid XML into these files!
For example, >br< without being closed or escaped crops up.
See 6.4 VML - SpreadsheetML Drawing in Office Open XML Part 4 - Markup Language Reference.pdf
@author Yegor Kozlov
regexp to parse shape ids, in VML they have weird form of id="_x0000_s1026"
Create a new SpreadsheetML Drawing
@see XSSFSheet#CreateDrawingPatriarch()
Construct a SpreadsheetML Drawing from a namespace part
@param part the namespace part holding the Drawing data,
the content type must be application/vnd.Openxmlformats-officedocument.Drawing+xml
@param rel the namespace relationship holding this Drawing,
the relationship type must be http://schemas.Openxmlformats.org/officeDocument/2006/relationships/drawing
Initialize a new Speadsheet VML Drawing
Find a shape with ClientData of type "NOTE" and the specified row and column
@return the comment shape or null
High level representation of a SpreadsheetML workbook. This is the first object most users
will construct whether they are Reading or writing a workbook. It is also the
top level object for creating new sheets/etc.
Width of one character of the default font in pixels. Same for Calibry and Arial.
Excel silently tRuncates long sheet names to 31 chars.
This constant is used to ensure uniqueness in the first 31 chars
Extended windows meta file
Windows Meta File
Mac PICT format
JPEG format
PNG format
Device independent bitmap
Images formats supported by XSSF but not by HSSF
The underlying XML bean
this holds the XSSFSheet objects attached to this workbook
this holds the XSSFName objects attached to this workbook, keyed by lower-case name
this holds the XSSFName objects attached to this workbook
shared string table - a cache of strings in this workbook
A collection of shared objects used for styling content,
e.g. fonts, cell styles, colors, etc.
The locator of user-defined functions.
By default includes functions from the Excel Analysis Toolpack
TODO
External Links, for referencing names or cells in other workbooks.
A collection of custom XML mappings
Used to keep track of the data formatter so that all
CreateDataFormatter calls return the same one for a given
book. This ensures that updates from one places is visible
someplace else.
The policy to apply in the event of missing or
blank cells when fetching from a row.
See {@link NPOI.ss.usermodel.Row.MissingCellPolicy}
array of pictures for this workbook
cached instance of XSSFCreationHelper for this workbook
@see {@link #getCreationHelper()}
List of all pivot tables in workbook
Create a new SpreadsheetML workbook.
Create a new SpreadsheetML workbook.
@param workbookType The type of workbook to make (.xlsx or .xlsm).
Constructs a XSSFWorkbook object given a OpenXML4J Package
object,
see http://poi.apache.org/oxml4j/.
Once you have finished working with the Workbook, you should close the package
by calling pkg.close, to avoid leaving file handles open.
Creating a XSSFWorkbook from a file-backed OPC Package has a lower memory
footprint than an InputStream backed one.
@param pkg the OpenXML4J OPC Package
object.
Constructs a XSSFWorkbook object, by buffering the whole stream into memory
and then opening an {@link OPCPackage} object for it.
Using an {@link InputStream} requires more memory than using a File, so
if a {@link File} is available then you should instead do something like
OPCPackage pkg = OPCPackage.open(path);
XSSFWorkbook wb = new XSSFWorkbook(pkg);
// work with the wb object
......
pkg.close(); // gracefully closes the underlying zip file
Not normally to be called externally, but possibly to be overridden to avoid
the DOM based parse of large sheets (see examples).
Create a new CT_Workbook with all values Set to default
Create a new SpreadsheetML namespace and Setup the default minimal content
Return the underlying XML bean
@return the underlying CT_Workbook bean
Adds a picture to the workbook.
@param pictureData The bytes of the picture
@param format The format of the picture.
@return the index to this picture (0 based), the Added picture can be obtained from {@link #getAllPictures()} .
@see Workbook#PICTURE_TYPE_EMF
@see Workbook#PICTURE_TYPE_WMF
@see Workbook#PICTURE_TYPE_PICT
@see Workbook#PICTURE_TYPE_JPEG
@see Workbook#PICTURE_TYPE_PNG
@see Workbook#PICTURE_TYPE_DIB
@see #getAllPictures()
Adds a picture to the workbook.
@param is The sream to read image from
@param format The format of the picture.
@return the index to this picture (0 based), the Added picture can be obtained from {@link #getAllPictures()} .
@see Workbook#PICTURE_TYPE_EMF
@see Workbook#PICTURE_TYPE_WMF
@see Workbook#PICTURE_TYPE_PICT
@see Workbook#PICTURE_TYPE_JPEG
@see Workbook#PICTURE_TYPE_PNG
@see Workbook#PICTURE_TYPE_DIB
@see #getAllPictures()
Create an XSSFSheet from an existing sheet in the XSSFWorkbook.
The Cloned sheet is a deep copy of the original.
@param sheetNum The index of the sheet to clone
@return XSSFSheet representing the Cloned sheet.
@throws ArgumentException if the sheet index in invalid
@throws POIXMLException if there were errors when cloning
Create an XSSFSheet from an existing sheet in the XSSFWorkbook.
The cloned sheet is a deep copy of the original but with a new given
name.
@param sheetNum The index of the sheet to clone
@param newName The name to set for the newly created sheet
@return XSSFSheet representing the cloned sheet.
@throws IllegalArgumentException if the sheet index or the sheet
name is invalid
@throws POIXMLException if there were errors when cloning
@since 3.14-Beta1
Generate a valid sheet name based on the existing one. Used when cloning sheets.
@param srcName the original sheet name to
@return clone sheet name
Create a new XSSFCellStyle and add it to the workbook's style table
the new XSSFCellStyle object
Returns the workbook's data format table (a factory for creating data format strings).
the XSSFDataFormat object
Create a new Font and add it to the workbook's font table
Create an XSSFSheet for this workbook, Adds it to the sheets and returns
the high level representation. Use this to create new sheets.
@return XSSFSheet representing the new sheet.
Create a new sheet for this Workbook and return the high level representation.
Use this to create new sheets.
Note that Excel allows sheet names up to 31 chars in length but other applications
(such as OpenOffice) allow more. Some versions of Excel crash with names longer than 31 chars,
others - tRuncate such names to 31 character.
POI's SpreadsheetAPI silently tRuncates the input argument to 31 characters.
Example:
Sheet sheet = workbook.CreateSheet("My very long sheet name which is longer than 31 chars"); // will be tRuncated
assert 31 == sheet.SheetName.Length;
assert "My very long sheet name which i" == sheet.SheetName;
Except the 31-character constraint, Excel applies some other rules:
Sheet name MUST be unique in the workbook and MUST NOT contain the any of the following characters:
- 0x0000
- 0x0003
- colon (:)
- backslash (\)
- asterisk (*)
- question mark (?)
- forward slash (/)
- opening square bracket ([)
- closing square bracket (])
The string MUST NOT begin or end with the single quote (') character.
See {@link org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)}
for a safe way to create valid names
@param sheetname sheetname to set for the sheet.
@return Sheet representing the new sheet.
@throws IllegalArgumentException if the name is null or invalid
or workbook already contains a sheet with this name
@see org.apache.poi.ss.util.WorkbookUtil#createSafeSheetName(String nameProposal)
Finds a font that matches the one with the supplied attributes
Finds a font that matches the one with the supplied attributes
Convenience method to Get the active sheet. The active sheet is is the sheet
which is currently displayed when the workbook is viewed in Excel.
'Selected' sheet(s) is a distinct concept.
Gets all pictures from the Workbook.
@return the list of pictures (a list of {@link XSSFPictureData} objects.)
@see #AddPicture(byte[], int)
Get the cell style object at the given index
@param idx index within the set of styles
@return XSSFCellStyle object at the index
Get the font at the given index number
@param idx index number
@return XSSFFont at the index
Get the first named range with the given name.
Note: names of named ranges are not unique as they are scoped by sheet.
{@link #getNames(String name)} returns all named ranges with the given name.
named range name
return XSSFName with the given name. null
is returned no named range could be found.
Get the named ranges with the given name.
Note:Excel named ranges are case-insensitive and
this method performs a case-insensitive search.
named range name
return list of XSSFNames with the given name. An empty list if no named ranges could be found
Get a list of all the named ranges in the workbook.
return list of XSSFNames in the workbook
Gets the named range index by his name
Note:Excel named ranges are case-insensitive and
this method performs a case-insensitive search.
@param name named range name
@return named range index
Get the number of styles the workbook Contains
@return count of cell styles
Get the number of fonts in the this workbook
@return number of fonts
Get the number of named ranges in the this workbook
@return number of named ranges
Get the number of worksheets in the this workbook
@return number of worksheets
Retrieves the reference for the printarea of the specified sheet, the sheet name is Appended to the reference even if it was not specified.
@param sheetIndex Zero-based sheet index (0 Represents the first sheet to keep consistent with java)
@return String Null if no print area has been defined
Get sheet with the given name (case insensitive match)
@param name of the sheet
@return XSSFSheet with the name provided or null
if it does not exist
Returns the index of the sheet by his name (case insensitive match)
the sheet name
index of the sheet (0 based) or -1 if not found
Returns the index of the given sheet
@param sheet the sheet to look up
@return index of the sheet (0 based). -1 if not found
Get the sheet name
@param sheetIx Number
@return Sheet name
Allows foreach loops:
XSSFWorkbook wb = new XSSFWorkbook(package);
for(XSSFSheet sheet : wb){
}
Are we a normal workbook (.xlsx), or a
macro enabled workbook (.xlsm)?
As {@link #removeName(String)} is not necessarily unique
(name + sheet index is unique), this method is more accurate.
@param name the name to remove.
Delete the printarea for the sheet specified
@param sheetIndex 0-based sheet index (0 = First Sheet)
Removes sheet at the given index.
Care must be taken if the Removed sheet is the currently active or only selected sheet in
the workbook. There are a few situations when Excel must have a selection and/or active
sheet. (For example when printing - see Bug 40414).
This method Makes sure that if the Removed sheet was active, another sheet will become
active in its place. Furthermore, if the Removed sheet was the only selected sheet, another
sheet will become selected. The newly active/selected sheet will have the same index, or
one less if the Removed sheet was the last in the workbook.
@param index of the sheet (0-based)
Gracefully remove references to the sheet being deleted
@param index the 0-based index of the sheet to delete
Retrieves the current policy on what to do when
Getting missing or blank cells from a row.
The default is to return blank and null cells.
{@link MissingCellPolicy}
Validate sheet index
@param index the index to validate
@throws ArgumentException if the index is out of range (index
< 0 || index >= NumberOfSheets).
Gets the first tab that is displayed in the list of tabs in excel.
@return integer that Contains the index to the active sheet in this book view.
For the Convenience of Java Programmers maintaining pointers.
@see #setPrintArea(int, String)
@param sheetIndex Zero-based sheet index (0 = First Sheet)
@param startColumn Column to begin printarea
@param endColumn Column to end the printarea
@param startRow Row to begin the printarea
@param endRow Row to end the printarea
Generates a NameRecord to represent a built-in region
@return a new NameRecord
@throws ArgumentException if sheetNumber is invalid
@throws POIXMLException if such a name already exists in the workbook
We only Set one sheet as selected for compatibility with HSSF.
Set the sheet name.
@param sheetIndex sheet number (0 based)
@param sheetname the new sheet name
@throws ArgumentException if the name is null or invalid
or workbook already Contains a sheet with this name
@see {@link #CreateSheet(String)}
@see {@link NPOI.ss.util.WorkbookUtil#CreateSafeSheetName(String nameProposal)}
for a safe way to create valid names
Sets the order of appearance for a given sheet.
@param sheetname the name of the sheet to reorder
@param pos the position that we want to insert the sheet into (0 based)
marshal named ranges from the {@link #namedRanges} collection to the underlying CT_Workbook bean
Write the document to the specified stream, and optionally leave the stream open without closing it.
Returns SharedStringsTable - the cache of strings for this workbook
@return the shared string table
Return a object representing a collection of shared objects used for styling content,
e.g. fonts, cell styles, colors, etc.
Returns the Theme of current workbook.
Returns an object that handles instantiating concrete
classes of the various instances for XSSF.
Determines whether a workbook Contains the provided sheet name.
For the purpose of comparison, long names are tRuncated to 31 chars.
@param name the name to Test (case insensitive match)
@param excludeSheetIdx the sheet to exclude from the check or -1 to include all sheets in the Check.
@return true if the sheet Contains the name, false otherwise.
Gets a bool value that indicates whether the date systems used in the workbook starts in 1904.
The default value is false, meaning that the workbook uses the 1900 date system,
where 1/1/1900 is the first day in the system.
True if the date systems used in the workbook starts in 1904
Get the document's embedded files.
Check whether a sheet is hidden.
Note that a sheet could instead be Set to be very hidden, which is different
({@link #isSheetVeryHidden(int)})
@param sheetIx Number
@return true
if sheet is hidden
Check whether a sheet is very hidden.
This is different from the normal hidden status
({@link #isSheetHidden(int)})
@param sheetIx sheet index to check
@return true
if sheet is very hidden
Sets the visible state of this sheet.
Calling setSheetHidden(sheetIndex, true)
is equivalent to
setSheetHidden(sheetIndex, Workbook.SHEET_STATE_HIDDEN)
.
Calling setSheetHidden(sheetIndex, false)
is equivalent to
setSheetHidden(sheetIndex, Workbook.SHEET_STATE_VISIBLE)
.
@param sheetIx the 0-based index of the sheet
@param hidden whether this sheet is hidden
@see #setSheetHidden(int, int)
Hide or unhide a sheet.
- 0 - visible.
- 1 - hidden.
- 2 - very hidden.
@param sheetIx the sheet index (0-based)
@param state one of the following Workbook
constants:
Workbook.SHEET_STATE_VISIBLE
,
Workbook.SHEET_STATE_HIDDEN
, or
Workbook.SHEET_STATE_VERY_HIDDEN
.
@throws ArgumentException if the supplied sheet index or state is invalid
Hide or unhide a sheet.
The sheet number
0 for not hidden, 1 for hidden, 2 for very hidden
Fired when a formula is deleted from this workbook,
for example when calling cell.SetCellFormula(null)
@see XSSFCell#setCellFormula(String)
Return the CalculationChain object for this workbook
The calculation chain object specifies the order in which the cells in a workbook were last calculated
@return the CalculationChain
object or null
if not defined
* Returns the list of {@link ExternalLinksTable} object for this workbook
*
* The external links table specifies details of named ranges etc
* that are referenced from other workbooks, along with the last seen
* values of what they point to.
*
* Note that Excel uses index 0 for the current workbook, so the first
* External Links in a formula would be '[1]Foo' which corresponds to
* entry 0 in this list.
* @return the ExternalLinksTable
list, which may be empty
@return a collection of custom XML mappings defined in this workbook
@return the helper class used to query the custom XML mapping defined in this workbook
Adds the External Link Table part and relations required to allow formulas
referencing the specified external workbook to be added to this one. Allows
formulas such as "[MyOtherWorkbook.xlsx]Sheet3!$A$5" to be added to the
file, for workbooks not already linked / referenced.
@param name The name the workbook will be referenced as in formulas
@param workbook The open workbook to fetch the link required information from
Specifies a bool value that indicates whether structure of workbook is locked.
A value true indicates the structure of the workbook is locked. Worksheets in the workbook can't be Moved,
deleted, hidden, unhidden, or Renamed, and new worksheets can't be inserted.
A value of false indicates the structure of the workbook is not locked.
@return true if structure of workbook is locked
Specifies a bool value that indicates whether the windows that comprise the workbook are locked.
A value of true indicates the workbook windows are locked. Windows are the same size and position each time the
workbook is opened.
A value of false indicates the workbook windows are not locked.
@return true if windows that comprise the workbook are locked
Specifies a bool value that indicates whether the workbook is locked for revisions.
@return true if the workbook is locked for revisions.
Locks the structure of workbook.
Unlocks the structure of workbook.
Locks the windows that comprise the workbook.
Unlocks the windows that comprise the workbook.
Locks the workbook for revisions.
Unlocks the workbook for revisions.
Remove Pivot Tables and PivotCaches from the workbooka
Returns the locator of user-defined functions.
The default instance : the built-in functions with the Excel Analysis Tool Pack.
To Set / Evaluate custom functions you need to register them as follows:
@return wrapped instance of UDFFinder that allows seeking functions both by index and name
Register a new toolpack in this workbook.
@param toopack the toolpack to register
Whether the application shall perform a full recalculation when the workbook is opened.
Typically you want to force formula recalculation when you modify cell formulas or values
of a workbook previously Created by Excel. When Set to true, this flag will tell Excel
that it needs to recalculate all formulas in the workbook the next time the file is opened.
Note, that recalculation updates cached formula results and, thus, modifies the workbook.
Depending on the version, Excel may prompt you with "Do you want to save the Changes in filename?"
on close.
@param value true if the application will perform a full recalculation of
workbook values when the workbook is opened
@since 3.8
Whether Excel will be asked to recalculate all formulas when the workbook is opened.
@since 3.8
Returns the spreadsheet version (EXCLE2007) of this workbook
Returns the data table with the given name (case insensitive).
@param name the data table name (case-insensitive)
@return The Data table in the workbook named name, or null if no table is named name.
@since 3.15 beta 2
Add pivotCache to the workbook
Adds a vbaProject.bin file to the workbook. This will change the workbook
type if necessary.
@throws IOException
Adds a vbaProject.bin file taken from another, given workbook to this one.
@throws IOException
@throws InvalidFormatException
This is a seriously sick fix for the fact that some .xlsx
files contain raw bits of HTML, without being escaped
or properly turned into XML.
The result is that they contain things like >br<,
which breaks the XML parsing.
This very sick InputStream wrapper attempts to spot
these go past, and fix them.
Only works for UTF-8 and US-ASCII based streams!
It should only be used where experience Shows the problem
can occur...
Warning - doesn't fix!
Reads into the buffer from the spare bytes
We don't support .xlsb files, sorry
Helper class to extract text from an OOXML Word file
Should we also fetch the hyperlinks, when fetching
the text content? Default is to only output the
hyperlink label, and not the contents
Base class for XWPF paragraphs
@author Yury Batrakov (batrakov at gmail.com)
Decorator class for XWPFParagraph allowing to add comments
found in paragraph to its text
@author Yury Batrakov (batrakov at gmail.com)
A .docx file can have no headers/footers, the same header/footer
on each page, odd/even page footers, and optionally also
a different header/footer on the first page.
This class handles sorting out what there is, and giving you
the right headers and footers for the document.
Figures out the policy for the given document,
and Creates any header and footer objects
as required.
Figures out the policy for the given document,
and Creates any header and footer objects
as required.
MB 24 May 2010. Created this overloaded buildHdrFtr() method because testing demonstrated
that the XWPFFooter or XWPFHeader object returned by calls to the CreateHeader(int, XWPFParagraph[])
and CreateFooter(int, XWPFParagraph[]) methods or the GetXXXXXHeader/Footer methods where
headers or footers had been Added to a document since it had been Created/opened, returned
an object that Contained no XWPFParagraph objects even if the header/footer itself did contain
text. The reason was that this line of code; CTHdrFtr ftr = CTHdrFtr.Factory.NewInstance();
Created a brand new instance of the CTHDRFtr class which was then populated with data when
it should have recovered the CTHdrFtr object encapsulated within the XWPFHeaderFooter object
that had previoulsy been instantiated in the CreateHeader(int, XWPFParagraph[]) or
CreateFooter(int, XWPFParagraph[]) methods.
Returns the odd page header. This is
also the same as the default one...
Returns the odd page footer. This is
also the same as the default one...
Get the header that applies to the given
(1 based) page.
@param pageNumber The one based page number
Get the footer that applies to the given
(1 based) page.
@param pageNumber The one based page number
Base decorator class for XWPFParagraph
Experimental abstract class that is a base for XWPFSDT and XWPFSDTCell
WARNING - APIs expected to change rapidly.
These classes have so far been built only for Read-only Processing.
@return first SDT Title
@return first SDT Tag
@return the content object
@return null
@return document part
@return partType
@return element type
9 Jan 2010
// TODO insert Javadoc here!
@author epp
The different kinds of {@link IBody} that exist
Specifies all types of borders which can be specified for WordProcessingML
objects which have a border. Borders can be Separated into two types:
- Line borders: which specify a pattern to be used when Drawing a line around the
specified object.
- Art borders: which specify a repeated image to be used
when Drawing a border around the specified object. Line borders may be
specified on any object which allows a border, however, art borders may only
be used as a border at the page level - the borders under the pgBorders
element
@author Gisella Bronzetti
Specifies a line border consisting of a single line around the parent
object.
specifies an art border consisting of a repeated image of an apple
specifies an art border consisting of a repeated image of a shell pattern
specifies an art border consisting of a repeated image of a baby pacifier
specifies an art border consisting of a repeated image of a baby rattle
specifies an art border consisting of a repeated image of a set of
balloons
specifies an art border consisting of a repeated image of a hot air
balloon
specifies an art border consisting of a repeating image of a black and
white background.
specifies an art border consisting of a repeating image of a black dot on
a white background.
specifies an art border consisting of a repeating image of a black and
white background
specifies an art border consisting of a repeating image of a black and
white background.
specifies an art border consisting of a repeating image of a black and
white background.
specifies an art border consisting of a repeating image of a white dot on
a black background.
specifies an art border consisting of a repeating image of a black and
white background.
specifies an art border consisting of a repeating image of a black and
white background.
specifies an art border consisting of a repeating image of a black and
white background
specifies an art border consisting of a repeating image of a black and
white background
specifies an art border consisting of a repeated image of bats
specifies an art border consisting of repeating images of birds
specifies an art border consisting of a repeated image of birds flying
specifies an art border consisting of a repeated image of a cabin
specifies an art border consisting of a repeated image of a piece of cake
specifies an art border consisting of a repeated image of candy corn
specifies an art border consisting of a repeated image of a knot work
pattern
specifies an art border consisting of a banner.
if the border is on the left or right, no border is displayed.
specifies an art border consisting of a repeating image of a chain link
pattern.
specifies an art border consisting of a repeated image of a champagne
bottle
specifies an art border consisting of repeating images of a compass
specifies an art border consisting of a repeating image of a colored
pattern.
specifies an art border consisting of a repeated image of a checkerboard
specifies an art border consisting of a repeated image of a christmas
tree
specifies an art border consisting of repeating images of lines and
circles
specifies an art border consisting of a repeated image of a rectangular
pattern
specifies an art border consisting of a repeated image of a wave
specifies an art border consisting of a repeated image of a clock
specifies an art border consisting of repeating images of a compass
specifies an art border consisting of a repeated image of confetti
specifies an art border consisting of a repeated image of confetti
specifies an art border consisting of a repeated image of confetti
specifies an art border consisting of a repeated image of confetti
streamers
specifies an art border consisting of a repeated image of confetti
specifies an art border consisting of a repeated image
specifies an art border consisting of a dashed line
specifies an art border consisting of a dotted line
specifies an art border consisting of a repeated image of a maze-like
pattern
specifies an art border consisting of a repeated image of a butterfly
specifies an art border consisting of a repeated image of a fish
specifies an art border consisting of repeating images of insects.
specifies an art border consisting of a repeated image of a ladybug
specifies an art border consisting of repeating images of a cross-stitch
pattern
specifies an art border consisting of a repeated image of cupid
Specifies the Set of possible restart locations which may be used as to
determine the next available line when a break's type attribute has a value
of textWrapping.
@author Gisella Bronzetti
Specifies that the text wrapping break shall advance the text to the next
line in the WordProcessingML document, regardless of its position left to
right or the presence of any floating objects which intersect with the
line,
This is the Setting for a typical line break in a document.
Specifies that the text wrapping break shall behave as follows:
- If this line is broken into multiple regions (a floating object in
the center of the page has text wrapping on both sides:
- If this is the leftmost region of text flow on this line, advance
the text to the next position on the line
- Otherwise, treat this as a text wrapping break of type all.
- If this line is not broken into multiple regions, then treat this
break as a text wrapping break of type none.
If the parent paragraph is right to left, then these behaviors are
also reversed.
Specifies that the text wrapping break shall advance the text to the next
line in the WordProcessingML document which spans the full width of the
line.
Specifies the possible types of break characters in a WordProcessingML
document.
The break type determines the next location where text shall be
placed After this manual break is applied to the text contents
@author Gisella Bronzetti
Specifies that the current break shall restart itself on the next page of
the document when the document is displayed in page view.
Specifies that the current break shall restart itself on the next column
available on the current page when the document is displayed in page
view.
If the current section is not divided into columns, or the column break
occurs in the last column on the current page when displayed, then the
restart location for text shall be the next page in the document.
Specifies that the current break shall restart itself on the next line in
the document when the document is displayed in page view.
The determine of the next line shall be done subject to the value of the clear
attribute on the specified break character.
Extended windows meta file
Windows Meta File
Mac PICT format
JPEG format
PNG format
Device independent bitmap
GIF image format
Tag Image File (.tiff)
Encapsulated Postscript (.eps)
Windows Bitmap (.bmp)
WordPerfect graphics (.wpg)
An IBody represents the different parts of the document which
can contain collections of Paragraphs and Tables. It provides a
common way to work with these and their contents.
Typically, this is something like a XWPFDocument, or one of
the parts in it like XWPFHeader, XWPFFooter, XWPFTableCell
returns the Part, to which the body belongs, which you need for Adding relationship to other parts
Actually it is needed of the class XWPFTableCell. Because you have to know to which part the tableCell
belongs.
@return the Part, to which the body belongs
Get the PartType of the body, for example
DOCUMENT, HEADER, FOOTER, FOOTNOTE,
@return the PartType of the body
Returns an Iterator with paragraphs and tables,
in the order that they occur in the text.
Returns the paragraph(s) that holds
the text of the header or footer.
Return the table(s) that holds the text
of the IBodyPart, for complex cases
where a paragraph isn't used.
if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this header or footer
the method will return this paragraph
if there is no corresponding {@link XWPFParagraph} the method will return null
@param p is instance of CTP and is searching for an XWPFParagraph
@return null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this header or footer
XWPFParagraph with the correspondig CTP p
if there is a corresponding {@link XWPFTable} of the parameter ctTable in the tableList of this header
the method will return this table
if there is no corresponding {@link XWPFTable} the method will return null
@param ctTable
Returns the paragraph that of position pos
Returns the table at position pos
inserts a new paragraph at position of the cursor
@param cursor
inserts a new Table at the cursor position.
@param cursor
inserts a new Table at position pos
@param pos
@param table
returns the TableCell to which the Table belongs
@param cell
Return XWPFDocument
9 Jan 2010
@author Philipp Epp
Simple interface describing both {@link XWPFParagraph}
and {@link XWPFSDT}
Common interface for things that can occur
where a run (text with common stylings) can,
eg {@link XWPFRun} or {@link XWPFSDT}.
More methods to follow shortly!
Experimental interface to offer rudimentary Read-only Processing of
of the contentblock of an SDT/ContentControl.
WARNING - APIs expected to change rapidly
Interface for anything that can be within an STD:
{@link XWPFRun}, {@link XWPFTable}, {@link XWPFParagraph},
{@link XWPFSDT} etc
Specifies the logic which shall be used to calculate the line spacing of the
parent object when it is displayed in the document.
@author Gisella Bronzetti
Specifies that the line spacing of the parent object shall be
automatically determined by the size of its contents, with no
predetermined minimum or maximum size.
Specifies that the height of the line shall be exactly the value
specified, regardless of the size of the contents If the contents are too
large for the specified height, then they shall be clipped as necessary.
Specifies that the height of the line shall be at least the value
specified, but may be expanded to fit its content as needed.
Specifies all types of alignment which are available to be applied to objects in a
WordProcessingML document
@author Yegor Kozlov
* postion of a character in a paragrapho
* 1st RunPositon
* 2nd TextPosition
* 3rd CharacterPosition
*
*
Specifies all types of vertical alignment which are available to be applied to of all text
on each line displayed within a paragraph.
@author Gisella Bronzetti
Specifies that all text in the parent object shall be
aligned to the top of each character when displayed
Specifies that all text in the parent object shall be
aligned to the center of each character when displayed.
Specifies that all text in the parent object shall be
aligned to the baseline of each character when displayed.
Specifies that all text in the parent object shall be
aligned to the bottom of each character when displayed.
Specifies that all text in the parent object shall be
aligned automatically when displayed.
saves the begin and end position of a text in a Paragraph
The index of the start run
The index of the start CT_Text
The index of the start text character
the index of the end CT_Text
the index of the end text character
Specifies the types of patterns which may be used to create the underline
applied beneath the text in a Run.
@author Gisella Bronzetti
Specifies an underline consisting of a single line beneath all characters
in this Run.
Specifies an underline consisting of a single line beneath all non-space
characters in the Run. There shall be no underline beneath any space
character (breaking or non-breaking).
Specifies an underline consisting of two lines beneath all characters in
this run
Specifies an underline consisting of a single thick line beneath all
characters in this Run.
Specifies an underline consisting of a series of dot characters beneath
all characters in this Run.
Specifies an underline consisting of a series of thick dot characters
beneath all characters in this Run.
Specifies an underline consisting of a dashed line beneath all characters
in this Run.
Specifies an underline consisting of a series of thick dashes beneath all
characters in this Run.
Specifies an underline consisting of long dashed characters beneath all
characters in this Run.
Specifies an underline consisting of thick long dashed characters beneath
all characters in this Run.
Specifies an underline consisting of a series of dash, dot characters
beneath all characters in this Run.
Specifies an underline consisting of a series of thick dash, dot
characters beneath all characters in this Run.
Specifies an underline consisting of a series of dash, dot, dot
characters beneath all characters in this Run.
Specifies an underline consisting of a series of thick dash, dot, dot
characters beneath all characters in this Run.
Specifies an underline consisting of a single wavy line beneath all
characters in this Run.
Specifies an underline consisting of a single thick wavy line beneath all
characters in this Run.
Specifies an underline consisting of a pair of wavy lines beneath all
characters in this Run.
Specifies no underline beneath this Run.
Specifies possible values for the alignment of the contents of this run in
relation to the default appearance of the Run's text. This allows the text to
be repositioned as subscript or superscript without altering the font size of
the run properties.
@author Gisella Bronzetti
Specifies that the text in the parent run shall be located at the
baseline and presented in the same size as surrounding text.
Specifies that this text should be subscript. This Setting shall lower
the text in this run below the baseline and change it to a smaller size,
if a smaller size is available.
Specifies that this text should be superscript. This Setting shall raise
the text in this run above the baseline and change it to a smaller size,
if a smaller size is available.
@author Philipp Epp
Abstract Numbering Definition Type
Numbering Definition Type
Single Level Numbering Definition
Multilevel Numbering Definition
Hybrid Multilevel Numbering Definition
Numbering Format
Decimal Numbers
Uppercase Roman Numerals
Lowercase Roman Numerals
Uppercase Latin Alphabet
Lowercase Latin Alphabet
Ordinal
Cardinal Text
Ordinal Text
Hexadecimal Numbering
Chicago Manual of Style
Ideographs
Japanese Counting System
AIUEO Order Hiragana
Iroha Ordered Katakana
Double Byte Arabic Numerals
Single Byte Arabic Numerals
Japanese Legal Numbering
Japanese Digital Ten Thousand Counting System
Decimal Numbers Enclosed in a Circle
Double Byte Arabic Numerals Alternate
Full-Width AIUEO Order Hiragana
Full-Width Iroha Ordered Katakana
Initial Zero Arabic Numerals
Bullet
Korean Ganada Numbering
Korean Chosung Numbering
Decimal Numbers Followed by a Period
Decimal Numbers Enclosed in Parenthesis
Decimal Numbers Enclosed in a Circle
Ideographs Enclosed in a Circle
Traditional Ideograph Format
Zodiac Ideograph Format
Traditional Zodiac Ideograph Format
Taiwanese Counting System
Traditional Legal Ideograph Format
Taiwanese Counting Thousand System
Taiwanese Digital Counting System
Chinese Counting System
Chinese Legal Simplified Format
Chinese Counting Thousand System
Korean Digital Counting System
Korean Counting System
Korean Legal Numbering
Korean Digital Counting System Alternate
Vietnamese Numerals
Lowercase Russian Alphabet
Uppercase Russian Alphabet
No Numbering
Number With Dashes
Hebrew Numerals
Hebrew Alphabet
Arabic Alphabet
Arabic Abjad Numerals
Hindi Vowels
Hindi Consonants
Hindi Numbers
Hindi Counting System
Thai Letters
Thai Numerals
Thai Counting System
* Sketch of XWPF comment class
*
* @author Yury Batrakov (batrakov at gmail.com)
*
Default Paragraph style, from which other styles will override
TODO Share logic with {@link XWPFParagraph} which also uses CTPPr
Default Character Run style, from which other styles will override
TODO Share logic with {@link XWPFRun} which also uses CTRPr
High(ish) level class for working with .docx files.
This class tries to hide some of the complexity
of the underlying file format, but as it's not a
mature and stable API yet, certain parts of the
XML structure come through. You'll therefore almost
certainly need to refer to the OOXML specifications
from
http://www.ecma-international.org/publications/standards/Ecma-376.htm
at some point in your use.
Keeps track on all id-values used in this document and included parts, like headers, footers, etc.
Handles the joy of different headers/footers for different pages
Create a new WordProcessingML package and Setup the default minimal content
Create a new CT_Document with all values Set to default
Returns the low level document base object
Sets columns on document base object
Sets Text Direction of Document
returns an Iterator with paragraphs and tables
@see NPOI.XWPF.UserModel.IBody#getBodyElements()
@see NPOI.XWPF.UserModel.IBody#getParagraphs()
@see NPOI.XWPF.UserModel.IBody#getTables()
@see NPOI.XWPF.UserModel.IBody#getTableArray(int)
@return the list of footers
@return the list of headers
Get the document part that's defined as the
given relationship of the core document.
Returns the policy on headers and footers, which
also provides a way to Get at them.
Returns the styles object used
Get the document's embedded files.
Finds that for example the 2nd entry in the body list is the 1st paragraph
Look up the paragraph at the specified position in the body elemnts list
and return this paragraphs position in the paragraphs list
@param pos
The position of the relevant paragraph in the body elements
list
@return the position of the paragraph in the paragraphs list, if there is
a paragraph at the position in the bodyelements list. Else it
will return -1
Get with the position of a table in the bodyelement array list
the position of this table in the table array list
@param pos position of the table in the bodyelement array list
@return if there is a table at the position in the bodyelement array list,
else it will return null.
Add a new paragraph at position of the cursor. The cursor must be on the
{@link org.apache.xmlbeans.XmlCursor.TokenType#START} tag of an subelement
of the documents body. When this method is done, the cursor passed as
parameter points to the {@link org.apache.xmlbeans.XmlCursor.TokenType#END}
of the newly inserted paragraph.
@param cursor
@return the {@link XWPFParagraph} object representing the newly inserted
CTP object
verifies that cursor is on the right position
@param cursor
Get the position of the paragraph, within the list
of all the body elements.
@param p The paragraph to find
@return The location, or -1 if the paragraph couldn't be found
Get the position of the table, within the list of
all the body elements.
@param t The table to find
@return The location, or -1 if the table couldn't be found
Commit and saves the document
Gets the index of the relation we're trying to create
@param relation
@return i
Appends a new paragraph to this document
@return a new paragraph
Creates an empty numbering if one does not already exist and Sets the numbering member
@return numbering
Creates an empty styles for the document if one does not already exist
@return styles
Creates an empty footnotes element for the document if one does not already exist
@return footnotes
remove a BodyElement from bodyElements array list
@param pos
@return true if removing was successfully, else return false
copies content of a paragraph to a existing paragraph in the list paragraphs at position pos
@param paragraph
@param pos
@return the LastParagraph of the document
Create an empty table with one row and one column as default.
@return a new table
Create an empty table with a number of rows and cols specified
@param rows
@param cols
@return table
Replace content of table in array tables at position pos with a
@param pos
@param table
Verifies that the documentProtection tag in settings.xml file
specifies that the protection is enforced (w:enforcement="1")
sample snippet from settings.xml
<w:settings ... >
<w:documentProtection w:edit="readOnly" w:enforcement="1"/>
@return true if documentProtection is enforced with option any
Verifies that the documentProtection tag in Settings.xml file
specifies that the protection is enforced (w:enforcement="1")
and that the kind of protection is ReadOnly (w:edit="readOnly")
sample snippet from Settings.xml
<w:settings ... >
<w:documentProtection w:edit="readOnly" w:enforcement="1"/>
@return true if documentProtection is enforced with option ReadOnly
Verifies that the documentProtection tag in Settings.xml file
specifies that the protection is enforced (w:enforcement="1")
and that the kind of protection is forms (w:edit="forms")
sample snippet from Settings.xml
<w:settings ... >
<w:documentProtection w:edit="forms" w:enforcement="1"/>
@return true if documentProtection is enforced with option forms
Verifies that the documentProtection tag in Settings.xml file
specifies that the protection is enforced (w:enforcement="1")
and that the kind of protection is comments (w:edit="comments")
sample snippet from Settings.xml
<w:settings ... >
<w:documentProtection w:edit="comments" w:enforcement="1"/>
@return true if documentProtection is enforced with option comments
Verifies that the documentProtection tag in Settings.xml file
specifies that the protection is enforced (w:enforcement="1")
and that the kind of protection is trackedChanges (w:edit="trackedChanges")
sample snippet from Settings.xml
<w:settings ... >
<w:documentProtection w:edit="trackedChanges" w:enforcement="1"/>
@return true if documentProtection is enforced with option trackedChanges
Enforces the ReadOnly protection.
In the documentProtection tag inside Settings.xml file,
it Sets the value of enforcement to "1" (w:enforcement="1")
and the value of edit to ReadOnly (w:edit="readOnly")
sample snippet from Settings.xml
<w:settings ... >
<w:documentProtection w:edit="readOnly" w:enforcement="1"/>
Enforce the Filling Forms protection.
In the documentProtection tag inside Settings.xml file,
it Sets the value of enforcement to "1" (w:enforcement="1")
and the value of edit to forms (w:edit="forms")
sample snippet from Settings.xml
<w:settings ... >
<w:documentProtection w:edit="forms" w:enforcement="1"/>
Enforce the Comments protection.
In the documentProtection tag inside Settings.xml file,
it Sets the value of enforcement to "1" (w:enforcement="1")
and the value of edit to comments (w:edit="comments")
sample snippet from Settings.xml
<w:settings ... >
<w:documentProtection w:edit="comments" w:enforcement="1"/>
Enforce the Tracked Changes protection.
In the documentProtection tag inside Settings.xml file,
it Sets the value of enforcement to "1" (w:enforcement="1")
and the value of edit to trackedChanges (w:edit="trackedChanges")
sample snippet from Settings.xml
<w:settings ... >
<w:documentProtection w:edit="trackedChanges" w:enforcement="1"/>
Remove protection enforcement.
In the documentProtection tag inside Settings.xml file
it Sets the value of enforcement to "0" (w:enforcement="0")
Enforces fields update on document open (in Word).
In the settings.xml file
sets the updateSettings value to true (w:updateSettings w:val="true")
NOTICES:
- Causing Word to ask on open: "This document contains fields that may refer to other files. Do you want to update the fields in this document?"
(if "Update automatic links at open" is enabled)
- Flag is removed after saving with changes in Word
Check if revision tracking is turned on.
@return true
if revision tracking is turned on
inserts an existing XWPFTable to the arrays bodyElements and tables
@param pos
@param table
Returns all Pictures, which are referenced from the document itself.
@return a {@link List} of {@link XWPFPictureData}. The returned {@link List} is unmodifiable. Use #a
@return all Pictures in this package
Get the next free ImageNumber
@param format
@return the next free ImageNumber
@throws InvalidFormatException
returns the PictureData by blipID
@param blipID
@return XWPFPictureData of a specificID
GetNumbering
@return numbering
Get Styles
@return styles for this document
Get the paragraph with the CTP class p
@param p
@return the paragraph with the CTP class p
Get a table by its CTTbl-Object
@param ctTbl
@see NPOI.XWPF.UserModel.IBody#getTable(org.Openxmlformats.schemas.wordProcessingml.x2006.main.CTTbl)
@return a table by its CTTbl-Object or null
Returns the paragraph that of position pos
@see NPOI.XWPF.UserModel.IBody#getParagraphArray(int)
returns the Part, to which the body belongs, which you need for Adding relationship to other parts
Actually it is needed of the class XWPFTableCell. Because you have to know to which part the tableCell
belongs.
@see NPOI.XWPF.UserModel.IBody#getPart()
Get the PartType of the body, for example
DOCUMENT, HEADER, FOOTER, FOOTNOTE,
@see NPOI.XWPF.UserModel.IBody#getPartType()
Get the TableCell which belongs to the TableCell
@param cell
@author Yegor Kozlov
@since POI 3.14-Beta1
@since POI 3.14-Beta1
A run of text which is part of a field, such as Title
of Page number or Author.
Any given Field may be made up of multiple of these.
Sketch of XWPF footer class
save and Commit footer
Get the PartType of the body
@see NPOI.XWPF.UserModel.IBody#getPartType()
position in table array
The table at position pos
inserts an existing XWPFTable to the arrays bodyElements and tables
if there is a corresponding {@link XWPFTable} of the parameter ctTable in the tableList of this header
the method will return this table
if there is no corresponding {@link XWPFTable} the method will return null
@param ctTable
@see NPOI.XWPF.UserModel.IBody#getTable(CTTbl ctTable)
if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this header or footer
the method will return this paragraph
if there is no corresponding {@link XWPFParagraph} the method will return null
@param p is instance of CTP and is searching for an XWPFParagraph
@return null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this header or footer
XWPFParagraph with the correspondig CTP p
@see NPOI.XWPF.UserModel.IBody#getParagraph(CTP p)
Returns the paragraph that holds the text of the header or footer.
Get the TableCell which belongs to the TableCell
verifies that cursor is on the right position
@param cursor
@param cursor
@return the inserted table
@see NPOI.XWPF.UserModel.IBody#insertNewTbl(XmlCursor cursor)
add a new paragraph at position of the cursor
@param cursor
@return the inserted paragraph
@see NPOI.XWPF.UserModel.IBody#insertNewParagraph(XmlCursor cursor)
add a new table to the end of the footnote
@param table
@return the Added XWPFTable
add a new paragraph to the end of the footnote
@param paragraph
@return the Added XWPFParagraph
@see NPOI.XWPF.UserModel.IBody#getXWPFDocument()
returns the Part, to which the body belongs, which you need for Adding relationship to other parts
@see NPOI.XWPF.UserModel.IBody#getPart()
Get the PartType of the body
@see NPOI.XWPF.UserModel.IBody#getPartType()
Looks After the collection of Footnotes for a document
@author Mike McEuen (mceuen@hp.com)
Construct XWPFFootnotes from a package part
@param part the package part holding the data of the footnotes,
@param rel the package relationship of type "http://schemas.Openxmlformats.org/officeDocument/2006/relationships/footnotes"
Construct XWPFFootnotes from scratch for a new document.
Read document
Sets the ctFootnotes
@param footnotes
add an XWPFFootnote to the document
@param footnote
@throws IOException
add a footnote to the document
@param note
@throws IOException
@see NPOI.XWPF.UserModel.IBody#getPart()
Sketch of XWPF header class
Save and commit footer
Read the document
Get the PartType of the body
Parent of XWPF headers and footers
Returns the paragraph(s) that holds
the text of the header or footer.
Normally there is only the one paragraph, but
there could be more in certain cases, or
a table.
Return the table(s) that holds the text
of the header or footer, for complex cases
where a paragraph isn't used.
Normally there's just one paragraph, but some
complex headers/footers have a table or two
in Addition.
Returns the textual content of the header/footer,
by flattening out the text of its paragraph(s)
Set a new headerFooter
if there is a corresponding {@link XWPFTable} of the parameter ctTable in the tableList of this header
the method will return this table
if there is no corresponding {@link XWPFTable} the method will return null
@param ctTable
if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this header or footer
the method will return this paragraph
if there is no corresponding {@link XWPFParagraph} the method will return null
@param p is instance of CTP and is searching for an XWPFParagraph
@return null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this header or footer
XWPFParagraph with the correspondig CTP p
Returns the paragraph that holds
the text of the header or footer.
Get a List of all Paragraphs
@return a list of {@link XWPFParagraph}
Get all Pictures in this package
@return all Pictures in this package
Adds a picture to the document.
@param pictureData The picture data
@param format The format of the picture.
@return the index to this picture (0 based), the Added picture can be obtained from {@link #getAllPictures()} .
@throws InvalidFormatException
Adds a picture to the document.
@param is The stream to read image from
@param format The format of the picture.
@return the index to this picture (0 based), the Added picture can be obtained from {@link #getAllPictures()} .
@throws InvalidFormatException
@
returns the PictureData by blipID
@param blipID
@return XWPFPictureData of a specificID
@throws Exception
verifies that cursor is on the right position
@param cursor
Returns the table at position pos
@see NPOI.XWPF.UserModel.IBody#getTableArray(int)
inserts an existing XWPFTable to the arrays bodyElements and tables
@param pos
@param table
Get the TableCell which belongs to the TableCell
@param cell
returns the Part, to which the body belongs, which you need for Adding relationship to other parts
@see NPOI.XWPF.UserModel.IBody#getPart()
Adds a new paragraph at the end of the header or footer
* Sketch of XWPF hyperlink class
*
* @author Yury Batrakov (batrakov at gmail.com)
*
A run of text with a Hyperlink applied to it.
Any given Hyperlink may be made up of multiple of these.
Returns the ID of the hyperlink, if one is Set.
If this Hyperlink is an external reference hyperlink,
return the object for it.
checks whether specific LatentStyleID is a latentStyle
@author Philipp Epp
@author Philipp Epp
create a new styles object with an existing document
create a new XWPFNumbering object for use in a new document
read numbering form an existing package
save and Commit numbering
Sets the ctNumbering
@param numbering
Checks whether number with numID exists
@param numID
@return bool true if num exist, false if num not exist
add a new number to the numbering document
@param num
Add a new num with an abstractNumID
@return return NumId of the Added num
Add a new num with an abstractNumID and a numID
@param abstractNumID
@param numID
Get Num by NumID
@param numID
@return abstractNum with NumId if no Num exists with that NumID
null will be returned
Get AbstractNum by abstractNumID
@param abstractNumID
@return abstractNum with abstractNumId if no abstractNum exists with that abstractNumID
null will be returned
Compare AbstractNum with abstractNums of this numbering document.
If the content of abstractNum Equals with an abstractNum of the List in numbering
the Bigint Value of it will be returned.
If no equal abstractNum is existing null will be returned
@param abstractNum
@return Bigint
add a new AbstractNum and return its AbstractNumID
@param abstractNum
Add a new AbstractNum
@author antony liu
remove an existing abstractNum
@param abstractNumID
@return true if abstractNum with abstractNumID exists in NumberingArray,
false if abstractNum with abstractNumID not exists
return the abstractNumID
If the AbstractNumID not exists
return null
@param numID
@return abstractNumID
A Paragraph within a Document, Table, Header etc.
A paragraph has a lot of styling information, but the
actual text (possibly along with more styling) is held on
the child {@link XWPFRun}s.
For access to the document's hyperlink, comments, tables etc
Identifies (in order) the parts of the paragraph /
sub-paragraph that correspond to character text
runs, and builds the appropriate runs for these.
Return the textual content of the paragraph, including text from pictures
and std element in it.
Return styleID of the paragraph if style exist for this paragraph
if not, null will be returned
@return styleID as String
If style exist for this paragraph
NumId of the paragraph will be returned.
If style not exist null will be returned
@return NumID as Bigint
Returns Ilvl of the numeric style for this paragraph.
Returns null if this paragraph does not have numeric style.
@return Ilvl as BigInteger
Returns numbering format for this paragraph, eg bullet or
lowerLetter.
Returns null if this paragraph does not have numeric style.
Returns the text that should be used around the paragraph level numbers.
@return a string (e.g. "%1.") or null if the value is not found.
Gets the numstartOverride for the paragraph numbering for this paragraph.
@return returns the overridden start number or null if there is no override for this paragraph.
SetNumID of Paragraph
@param numPos
Set NumID and level of Paragraph
Returns the text of the paragraph, but not of any objects in the
paragraph
Returns any text from any suitable pictures in the paragraph
Returns the footnote text of the paragraph
@return the footnote text or empty string if the paragraph does not have footnotes
Returns the paragraph alignment which shall be applied to text in this
paragraph.
If this element is not Set on a given paragraph, its value is determined
by the Setting previously Set at any level of the style hierarchy (i.e.
that previous Setting remains unChanged). If this Setting is never
specified in the style hierarchy, then no alignment is applied to the
paragraph.
@return the paragraph alignment of this paragraph.
@return The raw alignment value, {@link #getAlignment()} is suggested
Returns the text vertical alignment which shall be applied to text in
this paragraph.
If the line height (before any Added spacing) is larger than one or more
characters on the line, all characters will be aligned to each other as
specified by this element.
If this element is omitted on a given paragraph, its value is determined
by the Setting previously Set at any level of the style hierarchy (i.e.
that previous Setting remains unChanged). If this Setting is never
specified in the style hierarchy, then the vertical alignment of all
characters on the line shall be automatically determined by the consumer.
@return the vertical alignment of this paragraph.
the top border for the paragraph
Specifies the border which shall be displayed below a Set of
paragraphs which have the same Set of paragraph border Settings.
the bottom border for the paragraph
Specifies the border which shall be displayed on the left side of the
page around the specified paragraph.
the left border for the paragraph
Specifies the border which shall be displayed on the right side of the
page around the specified paragraph.
@return ParagraphBorder - the right border for the paragraph
@see #setBorderRight(Borders)
@see Borders for a list of all possible borders
Specifies the border which shall be displayed between each paragraph in a
Set of paragraphs which have the same Set of paragraph border Settings.
@return ParagraphBorder - the between border for the paragraph
@see #setBorderBetween(Borders)
@see Borders for a list of all possible borders
Specifies that when rendering this document in a paginated
view, the contents of this paragraph are rendered on the start of a new
page in the document.
If this element is omitted on a given paragraph,
its value is determined by the Setting previously Set at any level of the
style hierarchy (i.e. that previous Setting remains unChanged). If this
Setting is never specified in the style hierarchy, then this property
shall not be applied. Since the paragraph is specified to start on a new
page, it begins page two even though it could have fit on page one.
@return bool - if page break is Set
Specifies the spacing that should be Added After the last line in this
paragraph in the document in absolute units.
@return int - value representing the spacing After the paragraph
Specifies the spacing that should be Added After the last line in this
paragraph in the document in absolute units.
@return bigint - value representing the spacing After the paragraph
@see #setSpacingAfterLines(int)
Specifies the spacing that should be Added above the first line in this
paragraph in the document in absolute units.
@return the spacing that should be Added above the first line
@see #setSpacingBefore(int)
Specifies the spacing that should be Added before the first line in this paragraph in the
document in line units.
The value of this attribute is specified in one hundredths of a line.
@return the spacing that should be Added before the first line in this paragraph
@see #setSpacingBeforeLines(int)
Specifies how the spacing between lines is calculated as stored in the
line attribute. If this attribute is omitted, then it shall be assumed to
be of a value auto if a line attribute value is present.
Return the spacing between lines of a paragraph. The units of the return value depends on the
. If AUTO, the return value is in lines, otherwise the return
value is in points
a double specifying points or lines.
Specifies the indentation which shall be placed between the left text
margin for this paragraph and the left edge of that paragraph's content
in a left to right paragraph, and the right text margin and the right
edge of that paragraph's text in a right to left paragraph
If this attribute is omitted, its value shall be assumed to be zero.
Negative values are defined such that the text is Moved past the text margin,
positive values Move the text inside the text margin.
@return indentation or null if indentation is not Set
Specifies the indentation which shall be placed between the right text
margin for this paragraph and the right edge of that paragraph's content
in a left to right paragraph, and the right text margin and the right
edge of that paragraph's text in a right to left paragraph
If this attribute is omitted, its value shall be assumed to be zero.
Negative values are defined such that the text is Moved past the text margin,
positive values Move the text inside the text margin.
@return indentation or null if indentation is not Set
Specifies the indentation which shall be Removed from the first line of
the parent paragraph, by moving the indentation on the first line back
towards the beginning of the direction of text flow.
This indentation is
specified relative to the paragraph indentation which is specified for
all other lines in the parent paragraph.
The firstLine and hanging
attributes are mutually exclusive, if both are specified, then the
firstLine value is ignored.
@return indentation or null if indentation is not Set
Specifies the Additional indentation which shall be applied to the first
line of the parent paragraph. This Additional indentation is specified
relative to the paragraph indentation which is specified for all other
lines in the parent paragraph.
The firstLine and hanging attributes are
mutually exclusive, if both are specified, then the firstLine value is
ignored.
If the firstLineChars attribute is also specified, then this
value is ignored.
If this attribute is omitted, then its value shall be
assumed to be zero (if needed).
@return indentation or null if indentation is not Set
This element specifies whether a consumer shall break Latin text which
exceeds the text extents of a line by breaking the word across two lines
(breaking on the character level) or by moving the word to the following
line (breaking on the word level).
@return bool
@return the style of the paragraph
Get a copy of the currently used CTPBrd, if none is used, return
a new instance.
Get a copy of the currently used CTSpacing, if none is used,
return a new instance.
Get a copy of the currently used CTPInd, if none is used, return
a new instance.
Get a copy of the currently used CTPPr, if none is used, return
a new instance.
add a new run at the end of the position of
the content of parameter run
@param run
Replace text inside each run (cross run is not supported yet)
target text
replacement text
this methods parse the paragraph and search for the string searched.
If it finds the string, it will return true and the position of the String will be saved in the parameter startPos.
Appends a new run to this paragraph
@return a new text run
Appends a new OMath to this paragraph
@return a new text run
insert a new Run in RunArray
The position at which the new run should be added.
the inserted run or null if the given pos is out of bounds.
Get a Text
@param segment
Removes a Run at the position pos in the paragraph
@param pos
@return true if the run was Removed
returns the type of the BodyElement Paragraph
@see NPOI.XWPF.UserModel.IBodyElement#getElementType()
returns the part of the bodyElement
@see NPOI.XWPF.UserModel.IBody#getPart()
returns the partType of the bodyPart which owns the bodyElement
@see NPOI.XWPF.UserModel.IBody#getPartType()
Adds a new Run to the Paragraph
@param r
return the XWPFRun-Element which owns the CTR Run-Element
@param r
Appends a new hyperlink run to this paragraph
a new hyperlink run
@author Philipp Epp
Link Picture with PictureData
@param rel
Return the underlying CTPicture bean that holds all properties for this picture
@return the underlying CTPicture bean
Get the PictureData of the Picture, if present.
Note - not all kinds of picture have data
Raw picture data, normally attached to a WordProcessingML Drawing. As a rule, pictures are stored in the /word/media/ part of a WordProcessingML package.
@author Philipp Epp
Relationships for each known picture type
Create a new XWPFGraphicData node
Construct XWPFPictureData from a package part
@param part the package part holding the Drawing data,
@param rel the package relationship holding this Drawing,
the relationship type must be http://schemas.Openxmlformats.org/officeDocument/2006/relationships/image
Gets the picture data as a byte array.
Note, that this call might be expensive since all the picture data is copied into a temporary byte array.
You can grab the picture data directly from the underlying package part as follows:
InputStream is1 = GetPackagePart().InputStream;
@return the Picture data.
Returns the file name of the image, eg image7.jpg . The original filename
isn't always available, but if it can be found it's likely to be in the
CTDrawing
Suggests a file extension for this image.
@return the file extension.
Return an integer constant that specifies type of this picture
@return an integer constant that specifies type of this picture
@see NPOI.XWPF.UserModel.PictureTypeEMF
@see NPOI.XWPF.UserModel.PictureTypeWMF
@see NPOI.XWPF.UserModel.PictureTypePICT
@see NPOI.XWPF.UserModel.PictureTypeJPEG
@see NPOI.XWPF.UserModel.PictureTypePNG
@see NPOI.XWPF.UserModel.PictureTypeDIB
*PictureData objects store the actual content in the part directly without keeping a
copy like all others therefore we need to handle them differently.
@author Yegor Kozlov
A map to lookup POIXMLRelation by its relation type
Supported image formats
Get POIXMLRelation by relation type
@param rel relation type, for example,
http://schemas.openxmlformats.org/officeDocument/2006/relationships/image
@return registered POIXMLRelation or null if not found
@see [MS-OI29500] Run Fonts
XWPFrun.object defines a region of text with a common Set of properties
@author Yegor Kozlov
@author Gregg Morris (gregg dot morris at gmail dot com) - added getColor(), setColor()
@param r the CT_R bean which holds the run.attributes
@param p the parent paragraph
@deprecated Use {@link XWPFRun#XWPFRun(CTR, IRunBody)}
Get the currently used CT_R object
@return CT_R object
Get the currently referenced paragraph/SDT object
@return current parent
Get the currently referenced paragraph, or null if a SDT object
@deprecated use {@link XWPFRun#getParent()} instead
@return The {@link XWPFDocument} instance, this run.belongs to, or
null
if parent structure (paragraph > document) is not properly Set.
For isBold, isItalic etc
Whether the bold property shall be applied to all non-complex script
characters in the contents of this run.when displayed in a document.
This formatting property is a toggle property, which specifies that its
behavior differs between its use within a style defInition and its use as
direct formatting. When used as part of a style defInition, Setting this
property shall toggle the current state of that property as specified up
to this point in the hierarchy (i.e. applied to not applied, and vice
versa). Setting it to false
(or an equivalent) shall
result in the current Setting remaining unChanged. However, when used as
direct formatting, Setting this property to true or false shall Set the
absolute state of the resulting property.
If this element is not present, the default value is to leave the
formatting applied at previous level in the style hierarchy. If this
element is never applied in the style hierarchy, then bold shall not be
applied to non-complex script characters.
@param value true
if the bold property is applied to
this run
Get text color. The returned value is a string in the hex form "RRGGBB".
Set text color.
@param rgbStr - the desired color, in the hex form "RRGGBB".
Return the string content of this text run
@return the text of this text run.or null
if not Set
Returns text embedded in pictures
Sets the text of this text run
the literal text which shall be displayed in the document
Sets the text of this text run.in the
the literal text which shall be displayed in the document
position in the text array (NB: 0 based)
Whether the italic property should be applied to all non-complex script
characters in the contents of this run.when displayed in a document.
@return true
if the italic property is applied
Specifies that the contents of this run.should be displayed along with an
underline appearing directly below the character heigh
@return the Underline pattern Applyed to this run
@see UnderlinePatterns
insert text at start index in the run
insert text
start index of the insertion in the run text
Specifies that the contents of this run.should be displayed along with an
underline appearing directly below the character heigh
If this element is not present, the default value is to leave the
formatting applied at previous level in the style hierarchy. If this
element is never applied in the style hierarchy, then an underline shall
not be applied to the contents of this run.
@param value -
underline type
@see UnderlinePatterns : all possible patterns that could be applied
Specifies that the contents of this run.shall be displayed with a single
horizontal line through the center of the line.
@return true
if the strike property is applied
Specifies that the contents of this run.shall be displayed with a single
horizontal line through the center of the line.
This formatting property is a toggle property, which specifies that its
behavior differs between its use within a style defInition and its use as
direct formatting. When used as part of a style defInition, Setting this
property shall toggle the current state of that property as specified up
to this point in the hierarchy (i.e. applied to not applied, and vice
versa). Setting it to false (or an equivalent) shall result in the
current Setting remaining unChanged. However, when used as direct
formatting, Setting this property to true or false shall Set the absolute
state of the resulting property.
If this element is not present, the default value is to leave the
formatting applied at previous level in the style hierarchy. If this
element is never applied in the style hierarchy, then strikethrough shall
not be applied to the contents of this run.
@param value true
if the strike property is applied to
this run
Specifies that the contents of this run shall be displayed with a double
horizontal line through the center of the line.
@return true
if the double strike property is applied
Specifies the alignment which shall be applied to the contents of this
run.in relation to the default appearance of the run.s text.
This allows the text to be repositioned as subscript or superscript without
altering the font size of the run.properties.
@return VerticalAlign
@see VerticalAlign all possible value that could be Applyed to this run
Specifies the fonts which shall be used to display the text contents of
this run. Specifies a font which shall be used to format all characters
in the ASCII range (0 - 127) within the parent run
@return a string representing the font family
Gets the font family for the specified font char range.
If fcr is null, the font char range "ascii" is used
@param fcr the font char range, defaults to "ansi"
@return a string representing the font famil
Specifies the fonts which shall be used to display the text contents of
this run. The default handling for fcr == null is to overwrite the
ascii font char range with the given font family and also set all not
specified font ranges
@param fontFamily
@param fcr FontCharRange or null for default handling
Specifies the font size which shall be applied to all non complex script
characters in the contents of this run.when displayed.
@return value representing the font size
This element specifies the amount by which text shall be raised or
lowered for this run.in relation to the default baseline of the
surrounding non-positioned text. This allows the text to be repositioned
without altering the font size of the contents.
If the val attribute is positive, then the parent run.shall be raised
above the baseline of the surrounding text by the specified number of
half-points. If the val attribute is negative, then the parent run.shall
be lowered below the baseline of the surrounding text by the specified
number of half-points.
*
If this element is not present, the default value is to leave the
formatting applied at previous level in the style hierarchy. If this
element is never applied in the style hierarchy, then the text shall not
be raised or lowered relative to the default baseline location for the
contents of this run.
@return a big integer representing the amount of text shall be "moved"
Specifies that a break shall be placed at the current location in the run
content.
A break is a special character which is used to override the
normal line breaking that would be performed based on the normal layout
of the document's contents.
@see #AddCarriageReturn()
Specifies that a break shall be placed at the current location in the run
content.
A break is a special character which is used to override the
normal line breaking that would be performed based on the normal layout
of the document's contents.
The behavior of this break character (the
location where text shall be restarted After this break) shall be
determined by its type values.
@see BreakType
Specifies that a break shall be placed at the current location in the run
content. A break is a special character which is used to override the
normal line breaking that would be performed based on the normal layout
of the document's contents.
The behavior of this break character (the
location where text shall be restarted After this break) shall be
determined by its type (in this case is BreakType.TEXT_WRAPPING as default) and clear attribute values.
@see BreakClear
Specifies that a tab shall be placed at the current location in
the run content.
Specifies that a carriage return shall be placed at the
current location in the run.content.
A carriage return is used to end the current line of text in
WordProcess.
The behavior of a carriage return in run.content shall be
identical to a break character with null type and clear attributes, which
shall end the current line and find the next available line on which to
continue.
The carriage return character forced the following text to be
restarted on the next available line in the document.
Adds a picture to the run. This method handles
attaching the picture data to the overall file.
@see NPOI.XWPF.UserModel.Document#PICTURE_TYPE_EMF
@see NPOI.XWPF.UserModel.Document#PICTURE_TYPE_WMF
@see NPOI.XWPF.UserModel.Document#PICTURE_TYPE_PICT
@see NPOI.XWPF.UserModel.Document#PICTURE_TYPE_JPEG
@see NPOI.XWPF.UserModel.Document#PICTURE_TYPE_PNG
@see NPOI.XWPF.UserModel.Document#PICTURE_TYPE_DIB
@param pictureData The raw picture data
@param pictureType The type of the picture, eg {@link Document#PICTURE_TYPE_JPEG}
@param width width in EMUs. To convert to / from points use {@link org.apache.poi.util.Units}
@param height height in EMUs. To convert to / from points use {@link org.apache.poi.util.Units}
@throws NPOI.Openxml4j.exceptions.InvalidFormatException
@throws IOException
Returns the embedded pictures of the run. These
are pictures which reference an external,
embedded picture image such as a .png or .jpg
Add the xml:spaces="preserve" attribute if the string has leading or trailing white spaces
@param xs the string to check
Returns the string version of the text, with tabs and
carriage returns in place of their xml equivalents.
Experimental class to offer rudimentary Read-only Processing of
of StructuredDocumentTags/ContentControl
WARNING - APIs expected to change rapidly
Experimental class to offer rudimentary Read-only Processing of
of StructuredDocumentTags/ContentControl that can appear
in a table row as if a table cell.
These can contain one or more cells or other SDTs within them.
WARNING - APIs expected to change rapidly
Experimental class to offer rudimentary Read-only Processing of
of the contentblock of an SDT/ContentControl.
WARNING - APIs expected to change rapidly
Experimental class to offer rudimentary Read-only Processing of
of the XWPFSDTCellContent.
WARNING - APIs expected to change rapidly
In the zoom tag inside Settings.xml file
it Sets the value of zoom
@return percentage as an integer of zoom level
Set zoom. In the zoom tag inside settings.xml file it sets the value of zoom
sample snippet from Settings.xml
<w:zoom w:percent="50" />
Verifies the documentProtection tag inside settings.xml file
if the protection is enforced (w:enforcement="1")
sample snippet from settings.xml
<w:settings ... >
<w:documentProtection w:edit="readOnly" w:enforcement="1"/>
@return true if documentProtection is enforced with option any
Verifies the documentProtection tag inside Settings.xml file
if the protection is enforced (w:enforcement="1")
and if the kind of protection Equals to passed (STDocProtect.Enum editValue)
sample snippet from Settings.xml
<w:settings ... >
<w:documentProtection w:edit="readOnly" w:enforcement="1"/>
@return true if documentProtection is enforced with option ReadOnly
Enforces the protection with the option specified by passed editValue.
In the documentProtection tag inside Settings.xml file
it Sets the value of enforcement to "1" (w:enforcement="1")
and the value of edit to the passed editValue (w:edit="[passed editValue]")
sample snippet from Settings.xml
<w:settings ... >
<w:documentProtection w:edit="[passed editValue]" w:enforcement="1"/>
Removes protection enforcement.
In the documentProtection tag inside Settings.xml file
it Sets the value of enforcement to "0" (w:enforcement="0")
Enforces fields update on document open (in Word).
In the settings.xml file
sets the updateSettings value to true (w:updateSettings w:val="true")
NOTICES:
- Causing Word to ask on open: "This document contains fields that may refer to other files. Do you want to update the fields in this document?"
(if "Update automatic links at open" is enabled)
- Flag is removed after saving with changes in Word
get or set revision tracking
@author Philipp Epp
constructor
@param style
constructor
@param style
@param styles
Get StyleID of the style
@return styleID StyleID of the style
Get Type of the Style
@return ctType
Set style
@param style
Get ctStyle
@return ctStyle
Get styles
@return styles the styles to which this style belongs
Get StyleID of the linked Style
Get StyleID of the next style
Compares the names of the Styles
@param compStyle
Holds details of built-in, default and user styles, which
apply to tables / paragraphs / lists etc.
Text within one of those with custom stylings has the style
information stored in the {@link XWPFRun}
Construct XWPFStyles from a package part
@param part the package part holding the data of the styles,
@param rel the package relationship of type "http://schemas.Openxmlformats.org/officeDocument/2006/relationships/styles"
Construct XWPFStyles from scratch for a new document.
Read document
Sets the ctStyles
@param styles
Checks whether style with styleID exist
@param styleID styleID of the Style in the style-Document
@return true if style exist, false if style not exist
add a style to the document
@param style
@throws IOException
get style by a styleID
@param styleID styleID of the searched style
@return style
Get the styles which are related to the parameter style and their relatives
this method can be used to copy all styles from one document to another document
@param style
@return a list of all styles which were used by this method
Get the styles which are related to parameter style
@param style
@return all Styles of the parameterList
Sets the default spelling language on ctStyles DocDefaults parameter
@param strSpellingLanguage
Sets the default East Asia spelling language on ctStyles DocDefaults parameter
@param strEastAsia
Sets the default font on ctStyles DocDefaults parameter
TODO Replace this with specific Setters for each type, possibly
on XWPFDefaultRunStyle
Get the style with the same name
if this style is not existing, return null
Get the default style which applies text runs in the document
Get the default paragraph style which applies to the document
Get the definition of all the Latent Styles
Sketch of XWPFTable class. Only table's text is being hold.
Specifies the contents of a table present in the document. A table is a set
of paragraphs (and other block-level content) arranged in rows and columns.
@return ctTbl object
add a new column for each row in this table
create a new XWPFTableRow object with as many cells as the number of columns defined in that moment
@return tableRow
@param pos - index of the row
@return the row at the position specified or null if no rows is defined or if the position is greather than the max size of rows array
@return width value
@return number of rows in table
Get the StyleID of the table
@return style-ID of the table
add a new Row to the table
@param row the row which should be Added
add a new Row to the table
at position pos
@param row the row which should be Added
inserts a new tablerow
@param pos
@return the inserted row
Remove a row at position pos from the table
@param pos position the Row in the Table
returns the type of the BodyElement Table
@see NPOI.XWPF.UserModel.IBodyElement#getElementType()
returns the part of the bodyElement
@see NPOI.XWPF.UserModel.IBody#getPart()
returns the partType of the bodyPart which owns the bodyElement
@see NPOI.XWPF.UserModel.IBody#getPartType()
returns the XWPFRow which belongs to the CTRow row
if this row is not existing in the table null will be returned
Represents a Cell within a {@link XWPFTable}. The
Cell is the thing that holds the actual content (paragraphs etc)
If a table cell does not include at least one block-level element, then this document shall be considered corrupt
returns an Iterator with paragraphs and tables
@see NPOI.XWPF.UserModel.IBody#getBodyElements()
returns a list of paragraphs
Add a Paragraph to this Table Cell
@return The paragraph which was Added
add a Paragraph to this TableCell
@param p the paragaph which has to be Added
Removes a paragraph of this tablecell
@param pos
if there is a corresponding {@link XWPFParagraph} of the parameter ctTable in the paragraphList of this table
the method will return this paragraph
if there is no corresponding {@link XWPFParagraph} the method will return null
@param p is instance of CTP and is searching for an XWPFParagraph
@return null if there is no XWPFParagraph with an corresponding CTPparagraph in the paragraphList of this table
XWPFParagraph with the correspondig CTP p
Add bottom border to cell
Border Style
Border Width
Border Spacing Measurement
Border Color
Add top border to cell
Border Style
Border Width
Border Spacing Measurement
Border Color
Add left border to cell
Border Style
Border Width
Border Spacing Measurement
Border Color
Add right border to cell
Border Style
Border Width
Border Color
Creates border with parameters
Border Style
Border Width
Border Spacing Measurement
Border Color
CT_Border object
Set cell color. This sets some associated values; for finer control
you may want to access these elements individually.
@param rgbStr - the desired cell color, in the hex form "RRGGBB".
Get cell color. Note that this method only returns the "fill" value.
@return RGB string of cell color
Set the vertical alignment of the cell.
@param vAlign - the desired alignment enum value
Get the vertical alignment of the cell.
@return the cell alignment enum value or null if no vertical alignment is set
add a new paragraph at position of the cursor
@param cursor
@return the inserted paragraph
verifies that cursor is on the right position
@see NPOI.XWPF.UserModel.IBody#getParagraphArray(int)
Get the to which the TableCell belongs
@see NPOI.XWPF.UserModel.IBody#getPart()
@see NPOI.XWPF.UserModel.IBody#getPartType()
Get a table by its CTTbl-Object
@see NPOI.XWPF.UserModel.IBody#getTable(org.Openxmlformats.schemas.wordProcessingml.x2006.main.CTTbl)
@see NPOI.XWPF.UserModel.IBody#getTableArray(int)
@see NPOI.XWPF.UserModel.IBody#getTables()
inserts an existing XWPFTable to the arrays bodyElements and tables
@see NPOI.XWPF.UserModel.IBody#insertTable(int, NPOI.XWPF.UserModel.XWPFTable)
extracts all text recursively through embedded tables and embedded SDTs
Get the TableCell which belongs to the TableCell
A row within an {@link XWPFTable}. Rows mostly just have
sizings and stylings, the interesting content lives inside
the child {@link XWPFTableCell}s
create a new XWPFTableCell and add it to the tableCell-list of this tableRow
@return the newly Created XWPFTableCell
Adds a new TableCell at the end of this tableRow
This element specifies the height of the current table row within the
current table. This height shall be used to determine the resulting
height of the table row, which may be absolute or relative (depending on
its attribute values). If omitted, then the table row shall automatically
resize its height to the height required by its contents (the equivalent
of an hRule value of auto).
@return height
create and return a list of all XWPFTableCell
who belongs to this row
@return a list of {@link XWPFTableCell}
create and return a list of all XWPFTableCell
who belongs to this row
@return a list of {@link XWPFTableCell}
returns the XWPFTableCell which belongs to the CTTC cell
if there is no XWPFTableCell which belongs to the parameter CTTc cell null will be returned
Return true if the "can't split row" value is true. The logic for this
attribute is a little unusual: a TRUE value means DON'T allow rows to
split, FALSE means allow rows to split.
@return true if rows can't be split, false otherwise.
Return true if a table's header row should be repeated at the top of a
table split across pages.
@return true if table's header row should be repeated at the top of each
page of table, false otherwise.
Create Accent
Create n-ary Operator Object
Subscript Object
Superscript Object
Fraction Object
Radical Object
Accent
This element specifies the accent function, consisting of a base
and a combining diacritical mark. If accPr is
omitted, the default accent is U+0302 (COMBINING CIRCUMFLEX ACCENT).
Single char or UTF, like: ̃
This tag, which is an abbreviation for “element”, serves several functions (18 total) including that of the base
argument of a mathematical object or function, the elements in an array, and the elements in boxes.If all
subelements are omitted, this element specifies the presence of an empty argument.
Radical Object
This element specifies the radical object, consisting of a radical, a base e, and an optional degree deg. [Example:
Example of rad are √𝑥
This element specifies the degree in the mathematical radical. This element is optional. When omitted, the
square root function, as in √𝑥, is assumed.
Radical expression element.
Fraction Object
This element specifies the fraction object, consisting of a numerator and denominator separated by a fraction
bar.The fraction bar can be horizontal or diagonal, depending on the fraction properties.The fraction object is
also used to represent the stack function, which places one element above another, with no fraction bar.
This element specifies the properties of the fraction object f. Properties of the Fraction object include the type
or style of the fraction.The fraction bar can be horizontal or diagonal, depending on the fraction properties.The
fraction object is also used to represent the stack function, which places one element above another, with no
fraction bar.
This element specifies the numerator of the Fraction object f
This element specifies the denominator of a fraction
n-ary Operator Object
This element specifies an n-ary object, consisting of an n-ary object, a base (or operand), and optional upper and
lower limits
This tag, which is an abbreviation for “element”, serves several functions (18 total) including that of the base
argument of a mathematical object or function, the elements in an array, and the elements in boxes.If all
subelements are omitted, this element specifies the presence of an empty argument.
This element specifies the subscript of the Pre-Sub-Superscript object sPre
This element specifies the superscript of the superscript object sSup.
Get Nary symbol
Sets ∑ char
Sets ⋃ char
Sets ∫ char
Sets ⋀ char
For isBold, isItalic etc
Specifies the fonts which shall be used to display the text contents of
this run.The default handling for fcr == null is to overwrite the
ascii font char range with the given font family and also set all not
specified font ranges
fontFamily
FontCharRange or null for default handling
Gets the font family for the specified font char range.
If fcr is null, the font char range "ascii" is used
Please use "Cambria Math"(set as default) font otherwise MS Word
don't open file, LibreOffice Writer open it normaly.
I think this is MS Word bug, because this is not standart.
the font char range, defaults to "ansi"
a string representing the font famil
Sets the text of this text run
the literal text which shall be displayed in the document
Sets the text of this text run.in the
the literal text which shall be displayed in the document
position in the text array (NB: 0 based)
Add the xml:spaces="preserve" attribute if the string has leading or trailing white spaces
the string to check
Subscript Object
his element specifies the subscript object sSub, which consists of a base e and a reduced-size scr placed below
and to the right, as in Xn
This tag, which is an abbreviation for “element”, serves several functions (18 total) including that of the base
argument of a mathematical object or function, the elements in an array, and the elements in boxes.If all
subelements are omitted, this element specifies the presence of an empty argument.
This element specifies the Superscript of the Pre-Sub-Superscript object sPre
Subscript Object
his element specifies the subscript object sSub, which consists of a base e and a reduced-size scr placed below
and to the right, as in Xn
This tag, which is an abbreviation for “element”, serves several functions (18 total) including that of the base
argument of a mathematical object or function, the elements in an array, and the elements in boxes.If all
subelements are omitted, this element specifies the presence of an empty argument.
This element specifies the subscript of the Pre-Sub-Superscript object sPre