git-svn-id: https://svn.apache.org/repos/asf/poi/branches/hssf_cryptoapi@1761376 13f79535-47bb-0310-9956-ffa450edef68tags/REL_3_16_BETA1
7PoqJGZ6UdBVwyb0qZqs6KLGQkEyJ8358ivjJsjxUR8diK027wWnW/s= | 7PoqJGZ6UdBVwyb0qZqs6KLGQkEyJ8358ivjJsjxUR8diK027wWnW/s= | ||||
=/Vu1 | =/Vu1 | ||||
-----END PGP PUBLIC KEY BLOCK----- | -----END PGP PUBLIC KEY BLOCK----- | ||||
pub 2048R/26062CE3 2014-08-17 [expires: 2016-08-16] | |||||
uid Andreas Beeker <kiwiwings@apache.org> | |||||
uid Andreas Beeker (kiwiwings) <andreas.beeker@gmx.de> | |||||
sub 2048R/EE864ED6 2014-08-17 [expires: 2016-08-16] | |||||
pub rsa2048/26062CE3 2014-08-17 [expires: 2018-08-21] | |||||
uid [ultimate] Andreas Beeker <kiwiwings@apache.org> | |||||
uid [ultimate] Andreas Beeker (kiwiwings) <andreas.beeker@gmx.de> | |||||
sub rsa2048/EE864ED6 2014-08-17 [expires: 2018-08-21] | |||||
-----BEGIN PGP PUBLIC KEY BLOCK----- | -----BEGIN PGP PUBLIC KEY BLOCK----- | ||||
Version: GnuPG v2 | Version: GnuPG v2 | ||||
omzskuYgteTZ9Jn8efJMIymg9dGubuvN4HvUdEO0/u6K2MCZjIqNEPeqWIuZXeMb | omzskuYgteTZ9Jn8efJMIymg9dGubuvN4HvUdEO0/u6K2MCZjIqNEPeqWIuZXeMb | ||||
+4nGv2r0jSQAU94g3hueooqbUf+Mk2+H5O1d/h2Cii9qVvi6gELdVw9H+5Ir9AFc | +4nGv2r0jSQAU94g3hueooqbUf+Mk2+H5O1d/h2Cii9qVvi6gELdVw9H+5Ir9AFc | ||||
ynsmvxrPIxraBMPgrXmvPFOTlqlizyFv2O7pABEBAAG0JUFuZHJlYXMgQmVla2Vy | ynsmvxrPIxraBMPgrXmvPFOTlqlizyFv2O7pABEBAAG0JUFuZHJlYXMgQmVla2Vy | ||||
IDxraXdpd2luZ3NAYXBhY2hlLm9yZz6JAUEEEwECACsCGwMFCQPCZwAGCwkIBwMC | |||||
BhUIAgkKCwQWAgMBAh4BAheABQJUS6SzAhkBAAoJEKk+HEsmBizjjdYIALH3trht | |||||
6JTfPz2UsltFTcjzqLXG/I8Vq5hkr0s4ex1V7oNDXrBRBb1WC1pcEe1xqvQmoTyP | |||||
dUoX8lCyLOrt3IRpgjnH/4ACyenfOw6yHl6aaXX3HvseL3oHQTMpzkny+xVsrUzJ | |||||
wVCRVACPM49L6nRj4YRYaZqAn42x2peYHNcfFrvKsDtTnt4SbFQBlmuiDtlePM6a | |||||
9wzqXMFkX+9hcHp/SgOwDalpameoRQ/Itf1w2hN9dxYuaUWojo6b0XpChzkCHKix | |||||
uEKtjJXTovRlc6DzxT2Z5JMPhATiN3ZCo88lfd/kK8aMZgV4fruaq/QQRjNK/Hgn | |||||
6fP9jPARncSFHkCJAT4EEwECACgFAlPxECkCGwMFCQPCZwAGCwkIBwMCBhUIAgkK | |||||
IDxraXdpd2luZ3NAYXBhY2hlLm9yZz6JAUEEEwECACsCGwMGCwkIBwMCBhUIAgkK | |||||
CwQWAgMBAh4BAheAAhkBBQJXuYpTBQkHizsfAAoJEKk+HEsmBizjNa0H/AjJPguQ | |||||
WIn9AV/jstRN4OPM6eY7VUMG1DYoABRQSVsksPki5jZii0bI9VB3AUFgfXj0y6qk | |||||
CwQyKCJwZjcP3JuciJ5brQr/7D12hoTkYSCzCaECIpMoB7HWCpdoFusrgU2PUUwJ | |||||
i8xBTC+sLxIn3h5abTU68tnynCYhlA0mJ8zZ8CTvQJyEjidY1UgSohXClG2k/mo7 | |||||
z/IyW16x4dlpdkNfiBhL2v/5Ol7Vuz9g1lXvWvMdNQZ2PVK6w5dmCziCkih/qRgK | |||||
SUzn65ASEKiCN7afzUkCTdzrI71r3rOkJtlT1NWn2RAv6xT6AuhCPZzH2I3ImuFI | |||||
mkUKYhKzRN6AdmCJAT4EEwECACgFAlPxECkCGwMFCQPCZwAGCwkIBwMCBhUIAgkK | |||||
CwQWAgMBAh4BAheAAAoJEKk+HEsmBizjvfYIALS1vlaqN/f7/YzpnOwlH2Wo4jpI | CwQWAgMBAh4BAheAAAoJEKk+HEsmBizjvfYIALS1vlaqN/f7/YzpnOwlH2Wo4jpI | ||||
jBrG7SqcdVQk3NGsXTXzzq5p7uTTzpEJW8ReZLGeYaTzqh1vH97uAPR6wL3GjHMZ | jBrG7SqcdVQk3NGsXTXzzq5p7uTTzpEJW8ReZLGeYaTzqh1vH97uAPR6wL3GjHMZ | ||||
F2jkC0wSHXxvh9Gyrdx3LA8NSO+BAG9ZfD6OGklsl7tFFEplLpfR1EsAKfbi0bAY | F2jkC0wSHXxvh9Gyrdx3LA8NSO+BAG9ZfD6OGklsl7tFFEplLpfR1EsAKfbi0bAY | ||||
019qP30afGkvw+ZbIq8qbxJItObMuhn5xdI0YaMm2yudCfm2aGYSCnkrgNfuWzH6 | 019qP30afGkvw+ZbIq8qbxJItObMuhn5xdI0YaMm2yudCfm2aGYSCnkrgNfuWzH6 | ||||
WZ8n1fv45TGBUd2R6zPr13eH73AG1WXpapoD45yf/TFavRfnknU6xb7U3ZK0MkFu | WZ8n1fv45TGBUd2R6zPr13eH73AG1WXpapoD45yf/TFavRfnknU6xb7U3ZK0MkFu | ||||
ZHJlYXMgQmVla2VyIChraXdpd2luZ3MpIDxhbmRyZWFzLmJlZWtlckBnbXguZGU+ | ZHJlYXMgQmVla2VyIChraXdpd2luZ3MpIDxhbmRyZWFzLmJlZWtlckBnbXguZGU+ | ||||
iQE+BBMBAgAoBQJT8LY0AhsDBQkDwmcABgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIX | |||||
gAAKCRCpPhxLJgYs4wvFB/9hEV8LzHUpD0X/vM9pfW1ZbTl2GNiZfuMh6/KlqB3C | |||||
4gL3SLLRlk4mEPM3qlZWCqZiWVp5zz1C/j/+BLJW3c+j3rCUEAsobsR6HkxBr7N0 | |||||
LUnurbMXyiOvdg4lAS42Vi1JrydFdih1HCI3NiGMHAV/8NEdtmLt7Ue8Opx01R6r | |||||
wXBomX5BHJXnzbZRbCbdor/UnO8ff5K4jwd6yhY0BV+bI2uD+vGq9nMld0JGj7W7 | |||||
qB+HzOAxpINtHksQhtTV/PBWjHTCNhOdGh1zyoyvJSshm1NkvwBVZYMs/0ujApcq | |||||
xAXytGXonLiMmZMECOjxAigph8T4PCEKdIqdsVxkC2ybiQIcBBABCgAGBQJV5hIJ | |||||
iQE+BBMBAgAoAhsDBgsJCAcDAgYVCAIJCgsEFgIDAQIeAQIXgAUCV7mKXAUJB4s7 | |||||
HwAKCRCpPhxLJgYs4zheCACgc3m2FH5kmXtYO44BdYYwdV2dyLMCxvVl7GUWqJF8 | |||||
wKmDWlUxBwrpzDBQXpmHyb+rqX/kvfEkH2wb9TZwginLecbZbMKubNUWUqGJBHQo | |||||
CaV8o6L/iEUJa5NXzY2OJCp32CHsmpefYkU+WgAnmTVe8Se7JEmJeu+2OfStV5m6 | |||||
zVK5xzlciYSc29LpA3dsv5hxE6YZ8kJBJaFyv2AvVzaouSR7nPNrdw3/jXaOz+Hb | |||||
VpP/CEf5IdvF/o37sv8o7WWcH1AjvMdGQNp6Zr5Te2E35V8PmpqLH4Z8W0/PXij2 | |||||
67i565JZc1Kmpqxm59jg1vs2X7rHNn0k+r9BFiCQC1LKiQIcBBABCgAGBQJV5hIJ | |||||
AAoJEOGWdUUnufY1qh8P/03uvjuU1V9UZY9t/4J/K0wbU8Re9c/HfgmJrCn+wvDI | AAoJEOGWdUUnufY1qh8P/03uvjuU1V9UZY9t/4J/K0wbU8Re9c/HfgmJrCn+wvDI | ||||
OtxpOg3m07ZoIrosYEA2CIm+kLCYuNbzGSz6ZPZlpoq5FvxzO9OAYMO76r3ktxUw | OtxpOg3m07ZoIrosYEA2CIm+kLCYuNbzGSz6ZPZlpoq5FvxzO9OAYMO76r3ktxUw | ||||
Snbxd9TCkjCCQ8RMxT/JGDBU77nAJPyhCUZF2/SyrXnexloNP9TR/IDQZNOXzlxR | Snbxd9TCkjCCQ8RMxT/JGDBU77nAJPyhCUZF2/SyrXnexloNP9TR/IDQZNOXzlxR | ||||
nGL9OVoy1SdwTXgnboiIFtbTG3sVwD4x4qTRbmT22Ln/mIAICR2wxFBkzpbIQ7Mf | nGL9OVoy1SdwTXgnboiIFtbTG3sVwD4x4qTRbmT22Ln/mIAICR2wxFBkzpbIQ7Mf | ||||
R/zEgRh2VlRUUrWUsnYdOh0xfxuYgsnPCjpTY8hvEno3H6kzXKmj2GQJtawMVs5b | R/zEgRh2VlRUUrWUsnYdOh0xfxuYgsnPCjpTY8hvEno3H6kzXKmj2GQJtawMVs5b | ||||
Ro/GCM9lBBR/PAhB65ACzLmUUSsxjlmjZw0tCcOufg1RyAF/l6YVw1UOJaqXBfSP | Ro/GCM9lBBR/PAhB65ACzLmUUSsxjlmjZw0tCcOufg1RyAF/l6YVw1UOJaqXBfSP | ||||
eZkLQBj9p8VNpasX/acIfpEaZLE8QhoO11ajABEBAAGJASUEGAECAA8FAlPwtjQC | |||||
GwwFCQPCZwAACgkQqT4cSyYGLOPzLggAjHrdpMjZrHM5WqnxkJ1Eib1g14aScMGd | |||||
OIw9NOSQ2AGvJjbSy4xyMEUg3S14I73JGYtJu8g9YvCHbuWiyzySBIuGNinMI/Zj | |||||
ET/w1noqoNaSlIY4UfFh30g+OikEzP9WXmo0Scg0XH/fJhX1wCpM/TVlphX0yNGm | |||||
mkNBBqerRXC7Md4XOy001vvXZGM7vy+xOotyBOy/D4WNERSz3GVS3juCQGMWvMdq | |||||
KQa+qoiVaXWfFHwg8u4bSHunrzNja17GyaZHdCEmM9vFzlaqBkoLWCMwIcaKnX9s | |||||
tQJpFZwpzgut7DanaPcCDk7LMBbntaJwRC72M0qcj16SUAdAuGt1yQ== | |||||
=IonN | |||||
eZkLQBj9p8VNpasX/acIfpEaZLE8QhoO11ajABEBAAGJASUEGAECAA8CGwwFAle5 | |||||
inIFCQeLOz4ACgkQqT4cSyYGLOMvsAf+J2EyV9+GNqT8UmEU6OFnw/sdR1oE+vZ9 | |||||
fe4mifAfjQ+SKYf+MS0lU3lTuwcQKwFklePoYsvJEO7jNEgjTQ+zKiDSlV5yufSn | |||||
Idy8+sCYygPn5fSjGdRaMpCCfs5xrljLUPK5U8+vjeteRJW0o2/wmsYdHRz6A74B | |||||
kRq8kYu1M8VgZ6JD1YI/mp0mHTTB+H69/DNo6cA+7W/CibeTrffbJ35+OXGsJxqJ | |||||
b/QH/4lqsceNJtJThkHPQeM18R7/4t7Vhb5htOk2eB7coKzdYRKpHMzkm7elm8bI | |||||
uwsky9+6hIUMKD5hhc8G7g9lWOLSXCeNRUdqWTOfZaU5KOK70kKUeQ== | |||||
=PCbZ | |||||
-----END PGP PUBLIC KEY BLOCK----- | -----END PGP PUBLIC KEY BLOCK----- | ||||
pub 4096R/B4812553 2014-02-26 [expires: 2019-02-25] | pub 4096R/B4812553 2014-02-26 [expires: 2019-02-25] |
<description>The Apache POI project Ant build.</description> | <description>The Apache POI project Ant build.</description> | ||||
<property name="version.id" value="3.15-beta4"/> | |||||
<property name="version.id" value="3.16-beta1"/> | |||||
<property name="release.rc" value="RC1"/> | <property name="release.rc" value="RC1"/> | ||||
<property environment="env"/> | <property environment="env"/> | ||||
</copy> | </copy> | ||||
</target> | </target> | ||||
<target name="compile-integration" depends="compile-scratchpad, compile-main, compile-ooxml"> | |||||
<target name="compile-integration" depends="compile-scratchpad, compile-main, compile-ooxml, compile-examples"> | |||||
<javac target="${jdk.version.class}" | <javac target="${jdk.version.class}" | ||||
source="${jdk.version.source}" | source="${jdk.version.source}" | ||||
destdir="${integration.output.test.dir}" | destdir="${integration.output.test.dir}" | ||||
<!-- can't combine updating and pinning of the documentation ... so we need two commits --> | <!-- can't combine updating and pinning of the documentation ... so we need two commits --> | ||||
<!-- (revision)properties can't be set and read within one svn block --> | <!-- (revision)properties can't be set and read within one svn block --> | ||||
<echo message="updating build.xml and status.xml"/> | <echo message="updating build.xml and status.xml"/> | ||||
<exec command="svn ci --username ${settings.apache-id.username} --password ${settings.apache-id.password} -m 'release prepare for ${version.id} - updating build.xml and status.xml' build.xml src/documentation/content/xdocs/status.xml"/> | |||||
<svn refid="svn.settings"> | <svn refid="svn.settings"> | ||||
<commit message="release prepare for ${version.id} - updating build.xml and status.xml" recurse="false"> | |||||
<!--<commit message="release prepare for ${version.id} - updating build.xml and status.xml" recurse="false"> | |||||
<fileset dir="." includes="build.xml,src/documentation/content/xdocs/status.xml"/> | <fileset dir="." includes="build.xml,src/documentation/content/xdocs/status.xml"/> | ||||
</commit> | |||||
</commit>--> | |||||
<update dir="." recurse="true"/> | <update dir="." recurse="true"/> | ||||
<status path="." revisionProperty="svn_version1"/> | <status path="." revisionProperty="svn_version1"/> | ||||
</svn> | </svn> | ||||
<echo message="pin documentation - release ${svn_version1}"/> | <echo message="pin documentation - release ${svn_version1}"/> | ||||
<exec command="svn ci --username ${settings.apache-id.username} --password ${settings.apache-id.password} -m 'release prepare for ${version.id} - pin documentation' src"/> | |||||
<svn refid="svn.settings"> | <svn refid="svn.settings"> | ||||
<propset path="src" name="svn:externals" value="documentation -r${svn_version1} https://svn.apache.org/repos/asf/poi/site/src/documentation"/> | <propset path="src" name="svn:externals" value="documentation -r${svn_version1} https://svn.apache.org/repos/asf/poi/site/src/documentation"/> | ||||
<commit message="release prepare for ${version.id} - pin documentation" dir="src" recurse="false"/> | |||||
<!-- <commit message="release prepare for ${version.id} - pin documentation" dir="src" recurse="false"/>--> | |||||
<update dir="." recurse="true"/> | <update dir="." recurse="true"/> | ||||
<status path="." revisionProperty="svn_version2"/> | <status path="." revisionProperty="svn_version2"/> | ||||
</svn> | </svn> | ||||
<svn refid="svn.settings"> | <svn refid="svn.settings"> | ||||
<update dir="." recurse="true"/> | <update dir="." recurse="true"/> | ||||
<propset path="src" name="svn:externals" value="documentation https://svn.apache.org/repos/asf/poi/site/src/documentation"/> | <propset path="src" name="svn:externals" value="documentation https://svn.apache.org/repos/asf/poi/site/src/documentation"/> | ||||
<commit message="prepare for ${rel_next}" recurse="false"> | |||||
<!--<commit message="prepare for ${rel_next}" recurse="false"> | |||||
<fileset dir="." includes="build.xml"/> | <fileset dir="." includes="build.xml"/> | ||||
<fileset dir="sonar" includes="**/pom.xml"/> | <fileset dir="sonar" includes="**/pom.xml"/> | ||||
<dirset dir="src"/> | <dirset dir="src"/> | ||||
</commit> | |||||
</commit>--> | |||||
</svn> | </svn> | ||||
<exec command="svn ci --username ${settings.apache-id.username} --password ${settings.apache-id.password} -m 'prepare for ${rel_next}' build.xml sonar src"/> | |||||
<mkdir dir="build/release"/> | <mkdir dir="build/release"/> | ||||
<parent> | <parent> | ||||
<groupId>org.apache.poi</groupId> | <groupId>org.apache.poi</groupId> | ||||
<artifactId>poi-parent</artifactId> | <artifactId>poi-parent</artifactId> | ||||
<version>3.15-beta4-SNAPSHOT</version> | |||||
<version>3.16-beta1-SNAPSHOT</version> | |||||
</parent> | </parent> | ||||
<artifactId>poi-examples</artifactId> | <artifactId>poi-examples</artifactId> | ||||
<packaging>jar</packaging> | <packaging>jar</packaging> |
<parent> | <parent> | ||||
<groupId>org.apache.poi</groupId> | <groupId>org.apache.poi</groupId> | ||||
<artifactId>poi-parent</artifactId> | <artifactId>poi-parent</artifactId> | ||||
<version>3.15-beta4-SNAPSHOT</version> | |||||
<version>3.16-beta1-SNAPSHOT</version> | |||||
</parent> | </parent> | ||||
<artifactId>poi-excelant</artifactId> | <artifactId>poi-excelant</artifactId> | ||||
<packaging>jar</packaging> | <packaging>jar</packaging> |
<parent> | <parent> | ||||
<groupId>org.apache.poi</groupId> | <groupId>org.apache.poi</groupId> | ||||
<artifactId>poi-parent</artifactId> | <artifactId>poi-parent</artifactId> | ||||
<version>3.15-beta4-SNAPSHOT</version> | |||||
<version>3.16-beta1-SNAPSHOT</version> | |||||
</parent> | </parent> | ||||
<artifactId>poi-main</artifactId> | <artifactId>poi-main</artifactId> | ||||
<packaging>jar</packaging> | <packaging>jar</packaging> |
<parent> | <parent> | ||||
<groupId>org.apache.poi</groupId> | <groupId>org.apache.poi</groupId> | ||||
<artifactId>poi-parent</artifactId> | <artifactId>poi-parent</artifactId> | ||||
<version>3.15-beta4-SNAPSHOT</version> | |||||
<version>3.16-beta1-SNAPSHOT</version> | |||||
<relativePath>..</relativePath> | <relativePath>..</relativePath> | ||||
</parent> | </parent> | ||||
<artifactId>poi-ooxml-schema-encryption</artifactId> | <artifactId>poi-ooxml-schema-encryption</artifactId> |
<parent> | <parent> | ||||
<groupId>org.apache.poi</groupId> | <groupId>org.apache.poi</groupId> | ||||
<artifactId>poi-parent</artifactId> | <artifactId>poi-parent</artifactId> | ||||
<version>3.15-beta4-SNAPSHOT</version> | |||||
<version>3.16-beta1-SNAPSHOT</version> | |||||
<relativePath>..</relativePath> | <relativePath>..</relativePath> | ||||
</parent> | </parent> | ||||
<artifactId>poi-ooxml-schema-security</artifactId> | <artifactId>poi-ooxml-schema-security</artifactId> |
<parent> | <parent> | ||||
<groupId>org.apache.poi</groupId> | <groupId>org.apache.poi</groupId> | ||||
<artifactId>poi-parent</artifactId> | <artifactId>poi-parent</artifactId> | ||||
<version>3.15-beta4-SNAPSHOT</version> | |||||
<version>3.16-beta1-SNAPSHOT</version> | |||||
<relativePath>..</relativePath> | <relativePath>..</relativePath> | ||||
</parent> | </parent> | ||||
<artifactId>poi-ooxml-schema</artifactId> | <artifactId>poi-ooxml-schema</artifactId> |
<parent> | <parent> | ||||
<groupId>org.apache.poi</groupId> | <groupId>org.apache.poi</groupId> | ||||
<artifactId>poi-parent</artifactId> | <artifactId>poi-parent</artifactId> | ||||
<version>3.15-beta4-SNAPSHOT</version> | |||||
<version>3.16-beta1-SNAPSHOT</version> | |||||
</parent> | </parent> | ||||
<artifactId>poi-ooxml</artifactId> | <artifactId>poi-ooxml</artifactId> | ||||
<packaging>jar</packaging> | <packaging>jar</packaging> |
<groupId>org.apache.poi</groupId> | <groupId>org.apache.poi</groupId> | ||||
<artifactId>poi-parent</artifactId> | <artifactId>poi-parent</artifactId> | ||||
<packaging>pom</packaging> | <packaging>pom</packaging> | ||||
<version>3.15-beta4-SNAPSHOT</version> | |||||
<version>3.16-beta1-SNAPSHOT</version> | |||||
<name>Apache POI - the Java API for Microsoft Documents</name> | <name>Apache POI - the Java API for Microsoft Documents</name> | ||||
<description>Maven build of Apache POI for Sonar checks</description> | <description>Maven build of Apache POI for Sonar checks</description> | ||||
<url>http://poi.apache.org/</url> | <url>http://poi.apache.org/</url> |
<parent> | <parent> | ||||
<groupId>org.apache.poi</groupId> | <groupId>org.apache.poi</groupId> | ||||
<artifactId>poi-parent</artifactId> | <artifactId>poi-parent</artifactId> | ||||
<version>3.15-beta4-SNAPSHOT</version> | |||||
<version>3.16-beta1-SNAPSHOT</version> | |||||
</parent> | </parent> | ||||
<artifactId>poi-scratchpad</artifactId> | <artifactId>poi-scratchpad</artifactId> | ||||
<packaging>jar</packaging> | <packaging>jar</packaging> |
SVTableUtils.getAWTColor(s.getRightBorderColor(), SVTableUtils.black), | SVTableUtils.getAWTColor(s.getRightBorderColor(), SVTableUtils.black), | ||||
SVTableUtils.getAWTColor(s.getBottomBorderColor(), SVTableUtils.black), | SVTableUtils.getAWTColor(s.getBottomBorderColor(), SVTableUtils.black), | ||||
SVTableUtils.getAWTColor(s.getLeftBorderColor(), SVTableUtils.black), | SVTableUtils.getAWTColor(s.getLeftBorderColor(), SVTableUtils.black), | ||||
s.getBorderTop(), s.getBorderRight(), | |||||
s.getBorderBottom(), s.getBorderLeft(), | |||||
s.getBorderTopEnum(), s.getBorderRightEnum(), | |||||
s.getBorderBottomEnum(), s.getBorderLeftEnum(), | |||||
hasFocus); | hasFocus); | ||||
setBorder(cellBorder); | setBorder(cellBorder); | ||||
isBorderSet=true; | isBorderSet=true; |
String borderName; | String borderName; | ||||
switch (borderSide) { | switch (borderSide) { | ||||
case 't': default: | case 't': default: | ||||
b1 = style1.getBorderTop() == BorderStyle.THIN; | |||||
b2 = style2.getBorderTop() == BorderStyle.THIN; | |||||
b1 = style1.getBorderTopEnum() == BorderStyle.THIN; | |||||
b2 = style2.getBorderTopEnum() == BorderStyle.THIN; | |||||
borderName = "TOP"; | borderName = "TOP"; | ||||
break; | break; | ||||
case 'b': | case 'b': | ||||
b1 = style1.getBorderBottom() == BorderStyle.THIN; | |||||
b2 = style2.getBorderBottom() == BorderStyle.THIN; | |||||
b1 = style1.getBorderBottomEnum() == BorderStyle.THIN; | |||||
b2 = style2.getBorderBottomEnum() == BorderStyle.THIN; | |||||
borderName = "BOTTOM"; | borderName = "BOTTOM"; | ||||
break; | break; | ||||
case 'l': | case 'l': | ||||
b1 = style1.getBorderLeft() == BorderStyle.THIN; | |||||
b2 = style2.getBorderLeft() == BorderStyle.THIN; | |||||
b1 = style1.getBorderLeftEnum() == BorderStyle.THIN; | |||||
b2 = style2.getBorderLeftEnum() == BorderStyle.THIN; | |||||
borderName = "LEFT"; | borderName = "LEFT"; | ||||
break; | break; | ||||
case 'r': | case 'r': | ||||
b1 = style1.getBorderRight() == BorderStyle.THIN; | |||||
b2 = style2.getBorderRight() == BorderStyle.THIN; | |||||
b1 = style1.getBorderRightEnum() == BorderStyle.THIN; | |||||
b2 = style2.getBorderRightEnum() == BorderStyle.THIN; | |||||
borderName = "RIGHT"; | borderName = "RIGHT"; | ||||
break; | break; | ||||
} | } |
} | } | ||||
private void borderStyles(CellStyle style) { | private void borderStyles(CellStyle style) { | ||||
styleOut("border-left", style.getBorderLeft(), BORDER); | |||||
styleOut("border-right", style.getBorderRight(), BORDER); | |||||
styleOut("border-top", style.getBorderTop(), BORDER); | |||||
styleOut("border-bottom", style.getBorderBottom(), BORDER); | |||||
styleOut("border-left", style.getBorderLeftEnum(), BORDER); | |||||
styleOut("border-right", style.getBorderRightEnum(), BORDER); | |||||
styleOut("border-top", style.getBorderTopEnum(), BORDER); | |||||
styleOut("border-bottom", style.getBorderBottomEnum(), BORDER); | |||||
} | } | ||||
private void fontStyle(CellStyle style) { | private void fontStyle(CellStyle style) { |
import java.io.IOException; | import java.io.IOException; | ||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; | import org.apache.poi.openxml4j.exceptions.InvalidFormatException; | ||||
import org.apache.poi.ss.SpreadsheetVersion; | |||||
import org.apache.poi.ss.usermodel.Cell; | import org.apache.poi.ss.usermodel.Cell; | ||||
import org.apache.poi.ss.usermodel.DataConsolidateFunction; | import org.apache.poi.ss.usermodel.DataConsolidateFunction; | ||||
import org.apache.poi.ss.usermodel.Row; | import org.apache.poi.ss.usermodel.Row; | ||||
//Create some data to build the pivot table on | //Create some data to build the pivot table on | ||||
setCellData(sheet); | setCellData(sheet); | ||||
XSSFPivotTable pivotTable = sheet.createPivotTable(new AreaReference("A1:D4"), new CellReference("H5")); | |||||
AreaReference source = new AreaReference("A1:D4", SpreadsheetVersion.EXCEL2007); | |||||
CellReference position = new CellReference("H5"); | |||||
// Create a pivot table on this sheet, with H5 as the top-left cell.. | |||||
// The pivot table's data source is on the same sheet in A1:D4 | |||||
XSSFPivotTable pivotTable = sheet.createPivotTable(source, position); | |||||
//Configure the pivot table | //Configure the pivot table | ||||
//Use first column as row label | //Use first column as row label | ||||
pivotTable.addRowLabel(0); | pivotTable.addRowLabel(0); | ||||
Cell cell44 = row4.createCell(3); | Cell cell44 = row4.createCell(3); | ||||
cell44.setCellValue("No"); | cell44.setCellValue("No"); | ||||
} | } | ||||
} | |||||
} |
Sheet sheet = wb.createSheet("new sheet"); | Sheet sheet = wb.createSheet("new sheet"); | ||||
// Create a row and put some cells in it. Rows are 0 based. | // Create a row and put some cells in it. Rows are 0 based. | ||||
Row row = sheet.createRow((short) 1); | |||||
Row row = sheet.createRow(1); | |||||
// Aqua background | // Aqua background | ||||
CellStyle style = wb.createCellStyle(); | CellStyle style = wb.createCellStyle(); | ||||
style.setFillBackgroundColor(IndexedColors.AQUA.getIndex()); | style.setFillBackgroundColor(IndexedColors.AQUA.getIndex()); | ||||
style.setFillPattern(CellStyle.BIG_SPOTS); | style.setFillPattern(CellStyle.BIG_SPOTS); | ||||
Cell cell = row.createCell((short) 1); | |||||
Cell cell = row.createCell(1); | |||||
cell.setCellValue(new XSSFRichTextString("X")); | cell.setCellValue(new XSSFRichTextString("X")); | ||||
cell.setCellStyle(style); | cell.setCellStyle(style); | ||||
style = wb.createCellStyle(); | style = wb.createCellStyle(); | ||||
style.setFillForegroundColor(IndexedColors.ORANGE.getIndex()); | style.setFillForegroundColor(IndexedColors.ORANGE.getIndex()); | ||||
style.setFillPattern(CellStyle.SOLID_FOREGROUND); | style.setFillPattern(CellStyle.SOLID_FOREGROUND); | ||||
cell = row.createCell((short) 2); | |||||
cell = row.createCell(2); | |||||
cell.setCellValue(new XSSFRichTextString("X")); | cell.setCellValue(new XSSFRichTextString("X")); | ||||
cell.setCellStyle(style); | cell.setCellStyle(style); | ||||
EXPECTED_FAILURES.add("openxml4j/OPCCompliance_CoreProperties_OnlyOneCorePropertiesPartFAIL.docx"); | EXPECTED_FAILURES.add("openxml4j/OPCCompliance_CoreProperties_OnlyOneCorePropertiesPartFAIL.docx"); | ||||
EXPECTED_FAILURES.add("openxml4j/OPCCompliance_CoreProperties_UnauthorizedXMLLangAttributeFAIL.docx"); | EXPECTED_FAILURES.add("openxml4j/OPCCompliance_CoreProperties_UnauthorizedXMLLangAttributeFAIL.docx"); | ||||
EXPECTED_FAILURES.add("openxml4j/OPCCompliance_DerivedPartNameFAIL.docx"); | EXPECTED_FAILURES.add("openxml4j/OPCCompliance_DerivedPartNameFAIL.docx"); | ||||
EXPECTED_FAILURES.add("openxml4j/invalid.xlsx"); | |||||
EXPECTED_FAILURES.add("spreadsheet/54764-2.xlsx"); // see TestXSSFBugs.bug54764() | EXPECTED_FAILURES.add("spreadsheet/54764-2.xlsx"); // see TestXSSFBugs.bug54764() | ||||
EXPECTED_FAILURES.add("spreadsheet/54764.xlsx"); // see TestXSSFBugs.bug54764() | EXPECTED_FAILURES.add("spreadsheet/54764.xlsx"); // see TestXSSFBugs.bug54764() | ||||
EXPECTED_FAILURES.add("spreadsheet/Simple.xlsb"); | EXPECTED_FAILURES.add("spreadsheet/Simple.xlsb"); | ||||
List<Object[]> files = new ArrayList<Object[]>(); | List<Object[]> files = new ArrayList<Object[]>(); | ||||
for(String file : scanner.getIncludedFiles()) { | for(String file : scanner.getIncludedFiles()) { | ||||
file = file.replace('\\', '/'); // ... failures/handlers lookup doesn't work on windows otherwise | file = file.replace('\\', '/'); // ... failures/handlers lookup doesn't work on windows otherwise | ||||
if (IGNORED.contains(file)) continue; | |||||
if (IGNORED.contains(file)) { | |||||
System.out.println("Ignoring " + file); | |||||
continue; | |||||
} | |||||
FileHandler handler = HANDLERS.get(getExtension(file)); | FileHandler handler = HANDLERS.get(getExtension(file)); | ||||
files.add(new Object[] { file, handler }); | files.add(new Object[] { file, handler }); | ||||
import org.apache.poi.POIXMLException; | import org.apache.poi.POIXMLException; | ||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; | import org.apache.poi.openxml4j.exceptions.InvalidFormatException; | ||||
import org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException; | |||||
import org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException; | import org.apache.poi.openxml4j.exceptions.OLE2NotOfficeXmlFileException; | ||||
import org.apache.poi.openxml4j.exceptions.OpenXML4JException; | import org.apache.poi.openxml4j.exceptions.OpenXML4JException; | ||||
import org.apache.poi.openxml4j.opc.OPCPackage; | import org.apache.poi.openxml4j.opc.OPCPackage; | ||||
EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/Simple.xlsb"); | EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/Simple.xlsb"); | ||||
// TODO: good to ignore? | // TODO: good to ignore? | ||||
EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/sample-beta.xlsx"); | EXPECTED_ADDITIONAL_FAILURES.add("spreadsheet/sample-beta.xlsx"); | ||||
// corrupt/invalid | |||||
EXPECTED_ADDITIONAL_FAILURES.add("openxml4j/invalid.xlsx"); | |||||
} | } | ||||
@SuppressWarnings("resource") | @SuppressWarnings("resource") |
==================================================================== */ | ==================================================================== */ | ||||
package org.apache.poi.common.usermodel; | package org.apache.poi.common.usermodel; | ||||
import org.apache.poi.util.Removal; | |||||
/** | /** | ||||
* Represents a hyperlink. | * Represents a hyperlink. | ||||
*/ | */ | ||||
* | * | ||||
* @deprecated POI 3.15 beta 3. Use {@link HyperlinkType#URL} instead. | * @deprecated POI 3.15 beta 3. Use {@link HyperlinkType#URL} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
public static final int LINK_URL = 1; // HyperlinkType.URL.getCode() | public static final int LINK_URL = 1; // HyperlinkType.URL.getCode() | ||||
/** | /** | ||||
* | * | ||||
* @deprecated POI 3.15 beta 3. Use {@link HyperlinkType#DOCUMENT} instead. | * @deprecated POI 3.15 beta 3. Use {@link HyperlinkType#DOCUMENT} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
public static final int LINK_DOCUMENT = 2; // HyperlinkType.DOCUMENT.getCode() | public static final int LINK_DOCUMENT = 2; // HyperlinkType.DOCUMENT.getCode() | ||||
/** | /** | ||||
* | * | ||||
* @deprecated POI 3.15 beta 3. Use {@link HyperlinkType#EMAIL} instead. | * @deprecated POI 3.15 beta 3. Use {@link HyperlinkType#EMAIL} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
public static final int LINK_EMAIL = 3; // HyperlinkType.EMAIL.getCode() | public static final int LINK_EMAIL = 3; // HyperlinkType.EMAIL.getCode() | ||||
/** | /** | ||||
* | * | ||||
* @deprecated POI 3.15 beta 3. Use {@link HyperlinkType#FILE} instead. | * @deprecated POI 3.15 beta 3. Use {@link HyperlinkType#FILE} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
public static final int LINK_FILE = 4; // HyperlinkType.FILE.getCode() | public static final int LINK_FILE = 4; // HyperlinkType.FILE.getCode() | ||||
* @return the type of this hyperlink | * @return the type of this hyperlink | ||||
* @see HyperlinkType#forInt(int) | * @see HyperlinkType#forInt(int) | ||||
* @deprecated POI 3.15 beta 3. Use {@link #getTypeEnum()} | * @deprecated POI 3.15 beta 3. Use {@link #getTypeEnum()} | ||||
* getType will return a HyperlinkType enum in the future. | |||||
*/ | */ | ||||
public int getType(); | public int getType(); | ||||
package org.apache.poi.hssf.model; | package org.apache.poi.hssf.model; | ||||
import org.apache.poi.ss.formula.ptg.Ptg; | |||||
import org.apache.poi.util.Internal; | |||||
import org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook; | import org.apache.poi.hssf.usermodel.HSSFEvaluationWorkbook; | ||||
import org.apache.poi.hssf.usermodel.HSSFWorkbook; | import org.apache.poi.hssf.usermodel.HSSFWorkbook; | ||||
import org.apache.poi.ss.formula.FormulaParseException; | import org.apache.poi.ss.formula.FormulaParseException; | ||||
import org.apache.poi.ss.formula.FormulaParsingWorkbook; | import org.apache.poi.ss.formula.FormulaParsingWorkbook; | ||||
import org.apache.poi.ss.formula.FormulaRenderer; | import org.apache.poi.ss.formula.FormulaRenderer; | ||||
import org.apache.poi.ss.formula.FormulaType; | import org.apache.poi.ss.formula.FormulaType; | ||||
import org.apache.poi.ss.formula.ptg.Ptg; | |||||
import org.apache.poi.util.Internal; | |||||
import org.apache.poi.util.Removal; | |||||
/** | /** | ||||
* HSSF wrapper for the {@link FormulaParser} and {@link FormulaRenderer} | * HSSF wrapper for the {@link FormulaParser} and {@link FormulaRenderer} | ||||
* | * | ||||
* @deprecated POI 3.15 beta 3. Use {@link #parse(String, HSSFWorkbook, FormulaType)} instead. | * @deprecated POI 3.15 beta 3. Use {@link #parse(String, HSSFWorkbook, FormulaType)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
public static Ptg[] parse(String formula, HSSFWorkbook workbook, int formulaType) throws FormulaParseException { | public static Ptg[] parse(String formula, HSSFWorkbook workbook, int formulaType) throws FormulaParseException { | ||||
return parse(formula, workbook, FormulaType.forInt(formulaType)); | return parse(formula, workbook, FormulaType.forInt(formulaType)); | ||||
} | } | ||||
* @throws FormulaParseException if the formula has incorrect syntax or is otherwise invalid | * @throws FormulaParseException if the formula has incorrect syntax or is otherwise invalid | ||||
* @deprecated POI 3.15 beta 3. Use {@link #parse(String, HSSFWorkbook, FormulaType, int)} instead. | * @deprecated POI 3.15 beta 3. Use {@link #parse(String, HSSFWorkbook, FormulaType, int)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
public static Ptg[] parse(String formula, HSSFWorkbook workbook, int formulaType, int sheetIndex) throws FormulaParseException { | public static Ptg[] parse(String formula, HSSFWorkbook workbook, int formulaType, int sheetIndex) throws FormulaParseException { | ||||
return parse(formula, workbook, FormulaType.forInt(formulaType), sheetIndex); | return parse(formula, workbook, FormulaType.forInt(formulaType), sheetIndex); | ||||
} | } |
return borderFormatting; | return borderFormatting; | ||||
} | } | ||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderBottomEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
@Override | @Override | ||||
public BorderStyle getBorderBottom() { | |||||
public short getBorderBottom() { | |||||
return (short)borderFormatting.getBorderBottom(); | |||||
} | |||||
/** | |||||
* @since POI 3.15 | |||||
*/ | |||||
@Override | |||||
public BorderStyle getBorderBottomEnum() { | |||||
return BorderStyle.valueOf((short)borderFormatting.getBorderBottom()); | return BorderStyle.valueOf((short)borderFormatting.getBorderBottom()); | ||||
} | } | ||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderDiagonalEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
@Override | @Override | ||||
public BorderStyle getBorderDiagonal() { | |||||
public short getBorderDiagonal() { | |||||
return (short)borderFormatting.getBorderDiagonal(); | |||||
} | |||||
/** | |||||
* @since POI 3.15 | |||||
*/ | |||||
@Override | |||||
public BorderStyle getBorderDiagonalEnum() { | |||||
return BorderStyle.valueOf((short)borderFormatting.getBorderDiagonal()); | return BorderStyle.valueOf((short)borderFormatting.getBorderDiagonal()); | ||||
} | } | ||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderLeftEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
@Override | |||||
public short getBorderLeft() { | |||||
return (short)borderFormatting.getBorderLeft(); | |||||
} | |||||
/** | |||||
* @since POI 3.15 | |||||
*/ | |||||
@Override | @Override | ||||
public BorderStyle getBorderLeft() { | |||||
public BorderStyle getBorderLeftEnum() { | |||||
return BorderStyle.valueOf((short)borderFormatting.getBorderLeft()); | return BorderStyle.valueOf((short)borderFormatting.getBorderLeft()); | ||||
} | } | ||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderRightEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
@Override | |||||
public short getBorderRight() { | |||||
return (short)borderFormatting.getBorderRight(); | |||||
} | |||||
/** | |||||
* @since POI 3.15 | |||||
*/ | |||||
@Override | @Override | ||||
public BorderStyle getBorderRight() { | |||||
public BorderStyle getBorderRightEnum() { | |||||
return BorderStyle.valueOf((short)borderFormatting.getBorderRight()); | return BorderStyle.valueOf((short)borderFormatting.getBorderRight()); | ||||
} | } | ||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderTopEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
@Override | |||||
public short getBorderTop() { | |||||
return (short)borderFormatting.getBorderTop(); | |||||
} | |||||
/** | |||||
* @since POI 3.15 | |||||
*/ | |||||
@Override | @Override | ||||
public BorderStyle getBorderTop() { | |||||
public BorderStyle getBorderTopEnum() { | |||||
return BorderStyle.valueOf((short)borderFormatting.getBorderTop()); | return BorderStyle.valueOf((short)borderFormatting.getBorderTop()); | ||||
} | } | ||||
* | * | ||||
* Will return {@link CellType} in a future version of POI. | * Will return {@link CellType} in a future version of POI. | ||||
* For forwards compatibility, do not hard-code cell type literals in your code. | * For forwards compatibility, do not hard-code cell type literals in your code. | ||||
* @deprecated 3.15. Will be return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public int getCellType() | public int getCellType() | ||||
* @deprecated 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 be deleted when we make the CellType enum transition. See bug 59791. | ||||
*/ | */ | ||||
@Internal(since="POI 3.15 beta 3") | |||||
@Override | @Override | ||||
public CellType getCellTypeEnum() | public CellType getCellTypeEnum() | ||||
{ | { | ||||
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, | * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, | ||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending | * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending | ||||
* on the cached value of the formula | * on the cached value of the formula | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public int getCachedFormulaResultType() { | public int getCachedFormulaResultType() { | ||||
* @deprecated 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 be deleted when we make the CellType enum transition. See bug 59791. | ||||
*/ | */ | ||||
@Internal(since="POI 3.15 beta 3") | |||||
@Override | @Override | ||||
public CellType getCachedFormulaResultTypeEnum() { | public CellType getCachedFormulaResultTypeEnum() { | ||||
if (_cellType != CellType.FORMULA) { | if (_cellType != CellType.FORMULA) { |
import org.apache.poi.ss.usermodel.Font; | import org.apache.poi.ss.usermodel.Font; | ||||
import org.apache.poi.ss.usermodel.HorizontalAlignment; | import org.apache.poi.ss.usermodel.HorizontalAlignment; | ||||
import org.apache.poi.ss.usermodel.VerticalAlignment; | import org.apache.poi.ss.usermodel.VerticalAlignment; | ||||
import org.apache.poi.util.Removal; | |||||
/** | /** | ||||
* High level representation of the style of a cell in a sheet of a workbook. | * High level representation of the style of a cell in a sheet of a workbook. | ||||
* @see #ALIGN_CENTER_SELECTION | * @see #ALIGN_CENTER_SELECTION | ||||
* @deprecated POI 3.15 beta 3. Use {@link #setAlignment(HorizontalAlignment)} instead. | * @deprecated POI 3.15 beta 3. Use {@link #setAlignment(HorizontalAlignment)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setAlignment(short align) | public void setAlignment(short align) | ||||
{ | { | ||||
* @see VerticalAlignment | * @see VerticalAlignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link #setVerticalAlignment(VerticalAlignment)} instead. | * @deprecated POI 3.15 beta 3. Use {@link #setVerticalAlignment(VerticalAlignment)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setVerticalAlignment(short align) | public void setVerticalAlignment(short align) | ||||
{ | { | ||||
* @see #BORDER_SLANTED_DASH_DOT | * @see #BORDER_SLANTED_DASH_DOT | ||||
* @deprecated 3.15 beta 2. Use {@link HSSFCellStyle#setBorderLeft(BorderStyle)} instead. | * @deprecated 3.15 beta 2. Use {@link HSSFCellStyle#setBorderLeft(BorderStyle)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setBorderLeft(short border) | public void setBorderLeft(short border) | ||||
{ | { | ||||
/** | /** | ||||
* set the type of border to use for the left border of the cell | * set the type of border to use for the left border of the cell | ||||
* @param border type | * @param border type | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public void setBorderLeft(BorderStyle border) | public void setBorderLeft(BorderStyle border) | ||||
/** | /** | ||||
* get the type of border to use for the left border of the cell | * get the type of border to use for the left border of the cell | ||||
* @return border type | * @return border type | ||||
* @deprecated POI 3.15. Will return a BorderStyle enum in the future. Use {@link #getBorderLeftEnum()}. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public BorderStyle getBorderLeft() | |||||
public short getBorderLeft() | |||||
{ | |||||
return _format.getBorderLeft(); | |||||
} | |||||
/** | |||||
* get the type of border to use for the left border of the cell | |||||
* @return border type | |||||
* @since POI 3.15 | |||||
*/ | |||||
@Override | |||||
public BorderStyle getBorderLeftEnum() | |||||
{ | { | ||||
return BorderStyle.valueOf(_format.getBorderLeft()); | return BorderStyle.valueOf(_format.getBorderLeft()); | ||||
} | } | ||||
* @see #BORDER_SLANTED_DASH_DOT | * @see #BORDER_SLANTED_DASH_DOT | ||||
* @deprecated 3.15 beta 2. Use {@link HSSFCellStyle#setBorderRight(BorderStyle)} instead. | * @deprecated 3.15 beta 2. Use {@link HSSFCellStyle#setBorderRight(BorderStyle)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setBorderRight(short border) | public void setBorderRight(short border) | ||||
{ | { | ||||
/** | /** | ||||
* set the type of border to use for the right border of the cell | * set the type of border to use for the right border of the cell | ||||
* @param border type | * @param border type | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public void setBorderRight(BorderStyle border) | public void setBorderRight(BorderStyle border) | ||||
/** | /** | ||||
* get the type of border to use for the right border of the cell | * get the type of border to use for the right border of the cell | ||||
* @return border type | * @return border type | ||||
* @deprecated POI 3.15. Will return a BorderStyle enum in the future. Use {@link #getBorderRightEnum()}. | |||||
*/ | |||||
@Override | |||||
public short getBorderRight() | |||||
{ | |||||
return _format.getBorderRight(); | |||||
} | |||||
/** | |||||
* get the type of border to use for the right border of the cell | |||||
* @return border type | |||||
* @since POI 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public BorderStyle getBorderRight() | |||||
public BorderStyle getBorderRightEnum() | |||||
{ | { | ||||
return BorderStyle.valueOf(_format.getBorderRight()); | return BorderStyle.valueOf(_format.getBorderRight()); | ||||
} | } | ||||
* @see #BORDER_SLANTED_DASH_DOT | * @see #BORDER_SLANTED_DASH_DOT | ||||
* @deprecated 3.15 beta 2. Use {@link HSSFCellStyle#setBorderTop(BorderStyle)} instead. | * @deprecated 3.15 beta 2. Use {@link HSSFCellStyle#setBorderTop(BorderStyle)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setBorderTop(short border) | public void setBorderTop(short border) | ||||
{ | { | ||||
/** | /** | ||||
* set the type of border to use for the top border of the cell | * set the type of border to use for the top border of the cell | ||||
* @param border type | * @param border type | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public void setBorderTop(BorderStyle border) | public void setBorderTop(BorderStyle border) | ||||
/** | /** | ||||
* get the type of border to use for the top border of the cell | * get the type of border to use for the top border of the cell | ||||
* @return border type | * @return border type | ||||
* @deprecated POI 3.15. Will return a BorderStyle enum in the future. Use {@link #getBorderTopEnum()}. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public BorderStyle getBorderTop() | |||||
public short getBorderTop() | |||||
{ | |||||
return _format.getBorderTop(); | |||||
} | |||||
/** | |||||
* get the type of border to use for the top border of the cell | |||||
* @return border type | |||||
* @since 3.15 | |||||
*/ | |||||
@Override | |||||
public BorderStyle getBorderTopEnum() | |||||
{ | { | ||||
return BorderStyle.valueOf(_format.getBorderTop()); | return BorderStyle.valueOf(_format.getBorderTop()); | ||||
} | } | ||||
* @see #BORDER_SLANTED_DASH_DOT | * @see #BORDER_SLANTED_DASH_DOT | ||||
* @deprecated 3.15 beta 2. Use {@link HSSFCellStyle#setBorderBottom(BorderStyle)} instead. | * @deprecated 3.15 beta 2. Use {@link HSSFCellStyle#setBorderBottom(BorderStyle)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setBorderBottom(short border) | public void setBorderBottom(short border) | ||||
{ | { | ||||
/** | /** | ||||
* set the type of border to use for the bottom border of the cell | * set the type of border to use for the bottom border of the cell | ||||
* @param border type | * @param border type | ||||
* @since 3.15 beta 2 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public void setBorderBottom(BorderStyle border) | public void setBorderBottom(BorderStyle border) | ||||
/** | /** | ||||
* get the type of border to use for the bottom border of the cell | * get the type of border to use for the bottom border of the cell | ||||
* @return border type | * @return border type | ||||
* @deprecated POI 3.15. Will return a BorderStyle enum in the future. Use {@link #getBorderBottomEnum()}. | |||||
*/ | |||||
@Override | |||||
public short getBorderBottom() | |||||
{ | |||||
return _format.getBorderBottom(); | |||||
} | |||||
/** | |||||
* get the type of border to use for the bottom border of the cell | |||||
* @return border type | |||||
* @since 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public BorderStyle getBorderBottom() | |||||
public BorderStyle getBorderBottomEnum() | |||||
{ | { | ||||
return BorderStyle.valueOf(_format.getBorderBottom()); | return BorderStyle.valueOf(_format.getBorderBottom()); | ||||
} | } | ||||
* @param fp fill pattern (set to 1 to fill w/foreground color) | * @param fp fill pattern (set to 1 to fill w/foreground color) | ||||
* @deprecated POI 3.15 beta 3. Use {@link #setFillPattern(FillPatternType)} instead. | * @deprecated POI 3.15 beta 3. Use {@link #setFillPattern(FillPatternType)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setFillPattern(short fp) | public void setFillPattern(short fp) | ||||
{ | { |
import org.apache.poi.ddf.EscherRecord; | import org.apache.poi.ddf.EscherRecord; | ||||
import org.apache.poi.ss.SpreadsheetVersion; | import org.apache.poi.ss.SpreadsheetVersion; | ||||
import org.apache.poi.ss.usermodel.ClientAnchor; | import org.apache.poi.ss.usermodel.ClientAnchor; | ||||
import org.apache.poi.util.Removal; | |||||
/** | /** | ||||
* A client anchor is attached to an excel worksheet. It anchors against a | * A client anchor is attached to an excel worksheet. It anchors against a | ||||
/** | /** | ||||
* Gets the anchor type | * Gets the anchor type | ||||
* Changed from returning an int to an enum in POI 3.14 beta 1. | |||||
* @return the anchor type | * @return the anchor type | ||||
*/ | */ | ||||
@Override | @Override | ||||
/** | /** | ||||
* Sets the anchor type | * Sets the anchor type | ||||
* @param anchorType the anchor type to set | * @param anchorType the anchor type to set | ||||
* @since POI 3.14 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public void setAnchorType(AnchorType anchorType) { | public void setAnchorType(AnchorType anchorType) { | ||||
_escherClientAnchor.setFlag(anchorType.value); | _escherClientAnchor.setFlag(anchorType.value); | ||||
} | } | ||||
/** | |||||
* Sets the anchor type | |||||
* @param anchorType the anchor type to set | |||||
* @deprecated POI 3.15. Use {@link #setAnchorType(AnchorType)} instead. | |||||
*/ | |||||
@Removal(version="3.17") | |||||
@Override | |||||
public void setAnchorType(int anchorType) { | |||||
_escherClientAnchor.setFlag((short) anchorType); | |||||
} | |||||
private void checkRange(int value, int minRange, int maxRange, String varName) { | private void checkRange(int value, int minRange, int maxRange, String varName) { | ||||
if (value < minRange || value > maxRange) | if (value < minRange || value > maxRange) |
import org.apache.poi.hssf.record.common.ExtendedColor; | import org.apache.poi.hssf.record.common.ExtendedColor; | ||||
import org.apache.poi.ss.usermodel.CreationHelper; | import org.apache.poi.ss.usermodel.CreationHelper; | ||||
import org.apache.poi.util.Internal; | import org.apache.poi.util.Internal; | ||||
import org.apache.poi.util.Removal; | |||||
public class HSSFCreationHelper implements CreationHelper { | public class HSSFCreationHelper implements CreationHelper { | ||||
private final HSSFWorkbook workbook; | private final HSSFWorkbook workbook; | ||||
* @deprecated POI 3.15 beta 3. Use {@link #createHyperlink(HyperlinkType)} instead. | * @deprecated POI 3.15 beta 3. Use {@link #createHyperlink(HyperlinkType)} instead. | ||||
*/ | */ | ||||
@Deprecated | @Deprecated | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public HSSFHyperlink createHyperlink(int type) { | public HSSFHyperlink createHyperlink(int type) { | ||||
return new HSSFHyperlink(type); | return new HSSFHyperlink(type); |
* For forwards compatibility, do not hard-code cell type literals in your code. | * For forwards compatibility, do not hard-code cell type literals in your code. | ||||
* | * | ||||
* @return cell type | * @return cell type | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public int getCellType() { | public int getCellType() { | ||||
* @deprecated 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 be deleted when we make the CellType enum transition. See bug 59791. | ||||
*/ | */ | ||||
@Internal(since="POI 3.15 beta 3") | |||||
@Override | @Override | ||||
public CellType getCellTypeEnum() { | public CellType getCellTypeEnum() { | ||||
return _cell.getCellTypeEnum(); | return _cell.getCellTypeEnum(); | ||||
* For forwards compatibility, do not hard-code cell type literals in your code. | * For forwards compatibility, do not hard-code cell type literals in your code. | ||||
* | * | ||||
* @return cell type of cached formula result | * @return cell type of cached formula result | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public int getCachedFormulaResultType() { | public int getCachedFormulaResultType() { | ||||
* @deprecated 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 be deleted when we make the CellType enum transition. See bug 59791. | ||||
*/ | */ | ||||
@Internal(since="POI 3.15 beta 3") | |||||
@Override | @Override | ||||
public CellType getCachedFormulaResultTypeEnum() { | public CellType getCachedFormulaResultTypeEnum() { | ||||
return _cell.getCachedFormulaResultTypeEnum(); | return _cell.getCachedFormulaResultTypeEnum(); |
import org.apache.poi.ss.formula.eval.ValueEval; | import org.apache.poi.ss.formula.eval.ValueEval; | ||||
import org.apache.poi.ss.formula.udf.UDFFinder; | import org.apache.poi.ss.formula.udf.UDFFinder; | ||||
import org.apache.poi.ss.usermodel.Cell; | import org.apache.poi.ss.usermodel.Cell; | ||||
import org.apache.poi.ss.usermodel.CellType; | |||||
import org.apache.poi.ss.usermodel.CellValue; | import org.apache.poi.ss.usermodel.CellValue; | ||||
import org.apache.poi.ss.usermodel.FormulaEvaluator; | import org.apache.poi.ss.usermodel.FormulaEvaluator; | ||||
import org.apache.poi.ss.usermodel.RichTextString; | |||||
import org.apache.poi.ss.usermodel.Workbook; | import org.apache.poi.ss.usermodel.Workbook; | ||||
import org.apache.poi.util.Internal; | |||||
/** | /** | ||||
* Evaluates formula cells.<p/> | * Evaluates formula cells.<p/> | ||||
public static HSSFFormulaEvaluator create(HSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) { | public static HSSFFormulaEvaluator create(HSSFWorkbook workbook, IStabilityClassifier stabilityClassifier, UDFFinder udfFinder) { | ||||
return new HSSFFormulaEvaluator(workbook, stabilityClassifier, udfFinder); | return new HSSFFormulaEvaluator(workbook, stabilityClassifier, udfFinder); | ||||
} | } | ||||
@Override | |||||
protected RichTextString createRichTextString(String str) { | |||||
return new HSSFRichTextString(str); | |||||
} | |||||
/** | /** | ||||
public void notifySetFormula(Cell cell) { | public void notifySetFormula(Cell cell) { | ||||
_bookEvaluator.notifyUpdateCell(new HSSFEvaluationCell((HSSFCell)cell)); | _bookEvaluator.notifyUpdateCell(new HSSFEvaluationCell((HSSFCell)cell)); | ||||
} | } | ||||
/** | |||||
* If cell contains formula, it evaluates the formula, and saves the result of the formula. The | |||||
* cell remains as a formula cell. If the cell does not contain formula, rather than throwing an | |||||
* exception, this method returns {@link CellType#_NONE} and leaves the cell unchanged. | |||||
* | |||||
* Note that the type of the <em>formula result</em> is returned, so you know what kind of | |||||
* cached formula result is also stored with the formula. | |||||
* <pre> | |||||
* CellType evaluatedCellType = evaluator.evaluateFormulaCell(cell); | |||||
* </pre> | |||||
* Be aware that your cell will hold both the formula, and the result. If you want the cell | |||||
* replaced with the result of the formula, use {@link #evaluateInCell(org.apache.poi.ss.usermodel.Cell)} | |||||
* @param cell The cell to evaluate | |||||
* @return {@link CellType#_NONE} for non-formula cells, or the type of the <em>formula result</em> | |||||
* @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. | |||||
*/ | |||||
@Internal | |||||
@Override | |||||
public CellType evaluateFormulaCellEnum(Cell cell) { | |||||
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) { | |||||
return CellType._NONE; | |||||
} | |||||
CellValue cv = evaluateFormulaCellValue(cell); | |||||
// cell remains a formula cell, but the cached value is changed | |||||
setCellValue(cell, cv); | |||||
return cv.getCellType(); | |||||
} | |||||
/** | |||||
* If cell contains formula, it evaluates the formula, and | |||||
* puts the formula result back into the cell, in place | |||||
* of the old formula. | |||||
* Else if cell does not contain formula, this method leaves | |||||
* the cell unchanged. | |||||
* Note that the same instance of HSSFCell is returned to | |||||
* allow chained calls like: | |||||
* <pre> | |||||
* int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType(); | |||||
* </pre> | |||||
* Be aware that your cell value will be changed to hold the | |||||
* result of the formula. If you simply want the formula | |||||
* value computed for you, use {@link #evaluateFormulaCellEnum(Cell)}} | |||||
*/ | |||||
@Override | @Override | ||||
public HSSFCell evaluateInCell(Cell cell) { | public HSSFCell evaluateInCell(Cell cell) { | ||||
if (cell == null) { | |||||
return null; | |||||
} | |||||
HSSFCell result = (HSSFCell) cell; | |||||
if (cell.getCellTypeEnum() == CellType.FORMULA) { | |||||
CellValue cv = evaluateFormulaCellValue(cell); | |||||
setCellValue(cell, cv); | |||||
setCellType(cell, cv); // cell will no longer be a formula cell | |||||
} | |||||
return result; | |||||
} | |||||
private static void setCellValue(Cell cell, CellValue cv) { | |||||
CellType cellType = cv.getCellType(); | |||||
switch (cellType) { | |||||
case BOOLEAN: | |||||
cell.setCellValue(cv.getBooleanValue()); | |||||
break; | |||||
case ERROR: | |||||
cell.setCellErrorValue(cv.getErrorValue()); | |||||
break; | |||||
case NUMERIC: | |||||
cell.setCellValue(cv.getNumberValue()); | |||||
break; | |||||
case STRING: | |||||
cell.setCellValue(new HSSFRichTextString(cv.getStringValue())); | |||||
break; | |||||
case BLANK: | |||||
// never happens - blanks eventually get translated to zero | |||||
case FORMULA: | |||||
// this will never happen, we have already evaluated the formula | |||||
default: | |||||
throw new IllegalStateException("Unexpected cell value type (" + cellType + ")"); | |||||
} | |||||
return (HSSFCell) super.evaluateInCell(cell); | |||||
} | } | ||||
/** | /** |
* | * | ||||
* @return the type of this hyperlink | * @return the type of this hyperlink | ||||
* @see HyperlinkType#forInt | * @see HyperlinkType#forInt | ||||
* @deprecated POI 3.15. Use {@link #getTypeEnum()} instead. | |||||
* getType will return a HyperlinkType enum in the future. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public int getType() { | public int getType() { |
if (writable) { | if (writable) { | ||||
dst = channel.map(FileChannel.MapMode.READ_WRITE, position, length); | dst = channel.map(FileChannel.MapMode.READ_WRITE, position, length); | ||||
worked = 0; | worked = 0; | ||||
// remember the buffer for cleanup if necessary | |||||
buffersToClean.add(dst); | |||||
} else { | } else { | ||||
// Read | // Read | ||||
channel.position(position); | channel.position(position); | ||||
// Ready it for reading | // Ready it for reading | ||||
dst.position(0); | dst.position(0); | ||||
// remember the buffer for cleanup if necessary | |||||
buffersToClean.add(dst); | |||||
// All done | // All done | ||||
return dst; | return dst; | ||||
} | } |
* @param format The format of the picture. | * @param format The format of the picture. | ||||
* | * | ||||
* @return the picture data reference. | * @return the picture data reference. | ||||
* @since 3.15 beta 1 | |||||
*/ | */ | ||||
PictureData addPicture(InputStream is, PictureType format) throws IOException; | PictureData addPicture(InputStream is, PictureType format) throws IOException; | ||||
* @param format The format of the picture. | * @param format The format of the picture. | ||||
* | * | ||||
* @return the picture data reference | * @return the picture data reference | ||||
* @since 3.15 beta 1 | |||||
*/ | */ | ||||
PictureData addPicture(File pict, PictureType format) throws IOException; | PictureData addPicture(File pict, PictureType format) throws IOException; | ||||
* | * | ||||
* @param pictureData The picture data to find in the SlideShow | * @param pictureData The picture data to find in the SlideShow | ||||
* @return {@code null} if picture data is not found in this slideshow | * @return {@code null} if picture data is not found in this slideshow | ||||
* @since 3.15 beta 3 | |||||
*/ | */ | ||||
PictureData findPictureData(byte[] pictureData); | PictureData findPictureData(byte[] pictureData); | ||||
import org.apache.poi.ss.usermodel.DataFormatter; | import org.apache.poi.ss.usermodel.DataFormatter; | ||||
import org.apache.poi.ss.usermodel.DateUtil; | import org.apache.poi.ss.usermodel.DateUtil; | ||||
import org.apache.poi.ss.util.DateFormatConverter; | import org.apache.poi.ss.util.DateFormatConverter; | ||||
import org.apache.poi.util.Internal; | |||||
/** | /** | ||||
* Format a value according to the standard Excel behavior. This "standard" is | * Format a value according to the standard Excel behavior. This "standard" is | ||||
* <p/> | * <p/> | ||||
* An Excel format has up to four parts, separated by semicolons. Each part | * An Excel format has up to four parts, separated by semicolons. Each part | ||||
* specifies what to do with particular kinds of values, depending on the number | * specifies what to do with particular kinds of values, depending on the number | ||||
* of parts given: <dl> <dt>One part (example: <tt>[Green]#.##</tt>) <dd>If the | |||||
* value is a number, display according to this one part (example: green text, | |||||
* with up to two decimal points). If the value is text, display it as is. | |||||
* <dt>Two parts (example: <tt>[Green]#.##;[Red]#.##</tt>) <dd>If the value is a | |||||
* positive number or zero, display according to the first part (example: green | |||||
* of parts given: | |||||
* <dl> | |||||
* <dt>One part (example: <tt>[Green]#.##</tt>)</dt> | |||||
* <dd>If the value is a number, display according to this one part (example: green text, | |||||
* with up to two decimal points). If the value is text, display it as is.</dd> | |||||
* | |||||
* <dt>Two parts (example: <tt>[Green]#.##;[Red]#.##</tt>)</dt> | |||||
* <dd>If the value is a positive number or zero, display according to the first part (example: green | |||||
* text, with up to two decimal points); if it is a negative number, display | * text, with up to two decimal points); if it is a negative number, display | ||||
* according to the second part (example: red text, with up to two decimal | * according to the second part (example: red text, with up to two decimal | ||||
* points). If the value is text, display it as is. <dt>Three parts (example: | |||||
* <tt>[Green]#.##;[Black]#.##;[Red]#.##</tt>) <dd>If the value is a positive | |||||
* points). If the value is text, display it as is.</dd> | |||||
* | |||||
* <dt>Three parts (example: <tt>[Green]#.##;[Black]#.##;[Red]#.##</tt>)</dt> | |||||
* <dd>If the value is a positive | |||||
* number, display according to the first part (example: green text, with up to | * number, display according to the first part (example: green text, with up to | ||||
* two decimal points); if it is zero, display according to the second part | * two decimal points); if it is zero, display according to the second part | ||||
* (example: black text, with up to two decimal points); if it is a negative | * (example: black text, with up to two decimal points); if it is a negative | ||||
* number, display according to the third part (example: red text, with up to | * number, display according to the third part (example: red text, with up to | ||||
* two decimal points). If the value is text, display it as is. <dt>Four parts | |||||
* (example: <tt>[Green]#.##;[Black]#.##;[Red]#.##;[@]</tt>) <dd>If the value is | |||||
* a positive number, display according to the first part (example: green text, | |||||
* two decimal points). If the value is text, display it as is.</dd> | |||||
* | |||||
* <dt>Four parts (example: <tt>[Green]#.##;[Black]#.##;[Red]#.##;[@]</tt>)</dt> | |||||
* <dd>If the value is a positive number, display according to the first part (example: green text, | |||||
* with up to two decimal points); if it is zero, display according to the | * with up to two decimal points); if it is zero, display according to the | ||||
* second part (example: black text, with up to two decimal points); if it is a | * second part (example: black text, with up to two decimal points); if it is a | ||||
* negative number, display according to the third part (example: red text, with | * negative number, display according to the third part (example: red text, with | ||||
* up to two decimal points). If the value is text, display according to the | * up to two decimal points). If the value is text, display according to the | ||||
* fourth part (example: text in the cell's usual color, with the text value | * fourth part (example: text in the cell's usual color, with the text value | ||||
* surround by brackets). </dl> | |||||
* surround by brackets).</dd> | |||||
* </dl> | |||||
* <p/> | * <p/> | ||||
* A given format part may specify a given Locale, by including something | * A given format part may specify a given Locale, by including something | ||||
* like <tt>[$$-409]</tt> or <tt>[$£-809]</tt> or <tt>[$-40C]</tt>. These | * like <tt>[$$-409]</tt> or <tt>[$£-809]</tt> or <tt>[$-40C]</tt>. These | ||||
* @param cell The cell. | * @param cell The cell. | ||||
* | * | ||||
* @return The ultimate type of this cell. | * @return The ultimate type of this cell. | ||||
* @deprecated POI 3.15. This will return a CellType enum in the future | |||||
*/ | */ | ||||
public static int ultimateType(Cell cell) { | public static int ultimateType(Cell cell) { | ||||
return ultimateTypeEnum(cell).getCode(); | return ultimateTypeEnum(cell).getCode(); | ||||
* @deprecated 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 be deleted when we make the CellType enum transition. See bug 59791. | ||||
*/ | */ | ||||
@Internal(since="POI 3.15 beta 3") | |||||
public static CellType ultimateTypeEnum(Cell cell) { | public static CellType ultimateTypeEnum(Cell cell) { | ||||
CellType type = cell.getCellTypeEnum(); | CellType type = cell.getCellTypeEnum(); | ||||
if (type == CellType.FORMULA) | if (type == CellType.FORMULA) |
import org.apache.poi.ss.usermodel.CellType; | import org.apache.poi.ss.usermodel.CellType; | ||||
import org.apache.poi.ss.usermodel.CellValue; | import org.apache.poi.ss.usermodel.CellValue; | ||||
import org.apache.poi.ss.usermodel.FormulaEvaluator; | import org.apache.poi.ss.usermodel.FormulaEvaluator; | ||||
import org.apache.poi.ss.usermodel.RichTextString; | |||||
import org.apache.poi.ss.usermodel.Row; | import org.apache.poi.ss.usermodel.Row; | ||||
import org.apache.poi.ss.usermodel.Sheet; | import org.apache.poi.ss.usermodel.Sheet; | ||||
import org.apache.poi.ss.usermodel.Workbook; | import org.apache.poi.ss.usermodel.Workbook; | ||||
throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")"); | throw new IllegalStateException("Bad cell type (" + cell.getCellTypeEnum() + ")"); | ||||
} | } | ||||
} | } | ||||
/** | |||||
* If cell contains formula, it evaluates the formula, and | |||||
* puts the formula result back into the cell, in place | |||||
* of the old formula. | |||||
* Else if cell does not contain formula, this method leaves | |||||
* the cell unchanged. | |||||
* Note that the same instance of HSSFCell is returned to | |||||
* allow chained calls like: | |||||
* <pre> | |||||
* int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType(); | |||||
* </pre> | |||||
* Be aware that your cell value will be changed to hold the | |||||
* result of the formula. If you simply want the formula | |||||
* value computed for you, use {@link #evaluateFormulaCellEnum(Cell)}} | |||||
* @param cell | |||||
* @return the {@code cell} that was passed in, allowing for chained calls | |||||
*/ | |||||
@Override | |||||
public Cell evaluateInCell(Cell cell) { | |||||
if (cell == null) { | |||||
return null; | |||||
} | |||||
Cell result = cell; | |||||
if (cell.getCellTypeEnum() == CellType.FORMULA) { | |||||
CellValue cv = evaluateFormulaCellValue(cell); | |||||
setCellValue(cell, cv); | |||||
setCellType(cell, cv); // cell will no longer be a formula cell | |||||
} | |||||
return result; | |||||
} | |||||
protected abstract CellValue evaluateFormulaCellValue(Cell cell); | protected abstract CellValue evaluateFormulaCellValue(Cell cell); | ||||
* replaced with the result of the formula, use {@link #evaluateInCell(org.apache.poi.ss.usermodel.Cell)} | * replaced with the result of the formula, use {@link #evaluateInCell(org.apache.poi.ss.usermodel.Cell)} | ||||
* @param cell The cell to evaluate | * @param cell The cell to evaluate | ||||
* @return -1 for non-formula cells, or the type of the <em>formula result</em> | * @return -1 for non-formula cells, or the type of the <em>formula result</em> | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public int evaluateFormulaCell(Cell cell) { | public int evaluateFormulaCell(Cell cell) { | ||||
return evaluateFormulaCellEnum(cell).getCode(); | return evaluateFormulaCellEnum(cell).getCode(); | ||||
} | } | ||||
/** | |||||
* If cell contains formula, it evaluates the formula, | |||||
* and saves the result of the formula. The cell | |||||
* remains as a formula cell. | |||||
* Else if cell does not contain formula, this method leaves | |||||
* the cell unchanged. | |||||
* Note that the type of the formula result is returned, | |||||
* so you know what kind of value is also stored with | |||||
* the formula. | |||||
* <pre> | |||||
* CellType evaluatedCellType = evaluator.evaluateFormulaCellEnum(cell); | |||||
* </pre> | |||||
* Be aware that your cell will hold both the formula, | |||||
* and the result. If you want the cell replaced with | |||||
* the result of the formula, use {@link #evaluate(org.apache.poi.ss.usermodel.Cell)} } | |||||
* @param cell The cell to evaluate | |||||
* @return The type of the formula result (the cell's type remains as CellType.FORMULA however) | |||||
* If cell is not a formula cell, returns {@link CellType#_NONE} rather than throwing an exception. | |||||
* @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. | |||||
*/ | |||||
@Override | |||||
public CellType evaluateFormulaCellEnum(Cell cell) { | |||||
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) { | |||||
return CellType._NONE; | |||||
} | |||||
CellValue cv = evaluateFormulaCellValue(cell); | |||||
// cell remains a formula cell, but the cached value is changed | |||||
setCellValue(cell, cv); | |||||
return cv.getCellTypeEnum(); | |||||
} | |||||
protected static void setCellType(Cell cell, CellValue cv) { | protected static void setCellType(Cell cell, CellValue cv) { | ||||
CellType cellType = cv.getCellType(); | |||||
CellType cellType = cv.getCellTypeEnum(); | |||||
switch (cellType) { | switch (cellType) { | ||||
case BOOLEAN: | case BOOLEAN: | ||||
case ERROR: | case ERROR: | ||||
throw new IllegalStateException("Unexpected cell value type (" + cellType + ")"); | throw new IllegalStateException("Unexpected cell value type (" + cellType + ")"); | ||||
} | } | ||||
} | } | ||||
protected abstract RichTextString createRichTextString(String str); | |||||
protected void setCellValue(Cell cell, CellValue cv) { | |||||
CellType cellType = cv.getCellTypeEnum(); | |||||
switch (cellType) { | |||||
case BOOLEAN: | |||||
cell.setCellValue(cv.getBooleanValue()); | |||||
break; | |||||
case ERROR: | |||||
cell.setCellErrorValue(cv.getErrorValue()); | |||||
break; | |||||
case NUMERIC: | |||||
cell.setCellValue(cv.getNumberValue()); | |||||
break; | |||||
case STRING: | |||||
cell.setCellValue(createRichTextString(cv.getStringValue())); | |||||
break; | |||||
case BLANK: | |||||
// never happens - blanks eventually get translated to zero | |||||
case FORMULA: | |||||
// this will never happen, we have already evaluated the formula | |||||
default: | |||||
throw new IllegalStateException("Unexpected cell value type (" + cellType + ")"); | |||||
} | |||||
} | |||||
/** | /** | ||||
* Loops over all cells in all sheets of the supplied | * Loops over all cells in all sheets of the supplied |
* For forwards compatibility, do not hard-code cell type literals in your code. | * For forwards compatibility, do not hard-code cell type literals in your code. | ||||
* | * | ||||
* @return cell type | * @return cell type | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
int getCellType(); | int getCellType(); | ||||
/** | /** | ||||
* For forwards compatibility, do not hard-code cell type literals in your code. | * For forwards compatibility, do not hard-code cell type literals in your code. | ||||
* | * | ||||
* @return cell type of cached formula result | * @return cell type of cached formula result | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
int getCachedFormulaResultType(); | int getCachedFormulaResultType(); | ||||
/** | /** |
import org.apache.poi.ss.formula.ptg.RangePtg; | import org.apache.poi.ss.formula.ptg.RangePtg; | ||||
import org.apache.poi.ss.formula.ptg.UnionPtg; | import org.apache.poi.ss.formula.ptg.UnionPtg; | ||||
import org.apache.poi.ss.formula.ptg.ValueOperatorPtg; | import org.apache.poi.ss.formula.ptg.ValueOperatorPtg; | ||||
import org.apache.poi.util.Removal; | |||||
/** | /** | ||||
* This class performs 'operand class' transformation. Non-base tokens are classified into three | * This class performs 'operand class' transformation. Non-base tokens are classified into three | ||||
private final FormulaType _formulaType; | private final FormulaType _formulaType; | ||||
/** @deprecated POI 3.15 beta 3. */ | |||||
/** | |||||
* @deprecated POI 3.15 beta 3. Use {@code OperandClassTransformer(FormulaType)} instead. | |||||
*/ | |||||
@Removal(version="3.17") | |||||
public OperandClassTransformer(int formulaType) { | public OperandClassTransformer(int formulaType) { | ||||
this(FormulaType.forInt(formulaType)); | this(FormulaType.forInt(formulaType)); | ||||
} | } |
* For forwards compatibility, do not hard-code cell type literals in your code. | * For forwards compatibility, do not hard-code cell type literals in your code. | ||||
* | * | ||||
* @return cell type | * @return cell type | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public int getCellType() { | public int getCellType() { | ||||
* @deprecated 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 be deleted when we make the CellType enum transition. See bug 59791. | ||||
*/ | */ | ||||
@Internal(since="POI 3.15 beta 3") | |||||
@Override | @Override | ||||
public CellType getCellTypeEnum() { | public CellType getCellTypeEnum() { | ||||
return _cellType; | return _cellType; | ||||
* For forwards compatibility, do not hard-code cell type literals in your code. | * For forwards compatibility, do not hard-code cell type literals in your code. | ||||
* | * | ||||
* @return cell type of cached formula result | * @return cell type of cached formula result | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public int getCachedFormulaResultType() { | public int getCachedFormulaResultType() { | ||||
* @deprecated 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 be deleted when we make the CellType enum transition. See bug 59791. | ||||
*/ | */ | ||||
@Internal(since="POI 3.15 beta 3") | |||||
@Override | @Override | ||||
public CellType getCachedFormulaResultTypeEnum() { | public CellType getCachedFormulaResultTypeEnum() { | ||||
return _masterCell.getCachedFormulaResultTypeEnum(); | return _masterCell.getCachedFormulaResultTypeEnum(); |
package org.apache.poi.ss.formula.functions; | package org.apache.poi.ss.formula.functions; | ||||
import org.apache.poi.ss.formula.eval.BlankEval; | |||||
import org.apache.poi.ss.formula.eval.ErrorEval; | import org.apache.poi.ss.formula.eval.ErrorEval; | ||||
import org.apache.poi.ss.formula.eval.EvaluationException; | |||||
import org.apache.poi.ss.formula.eval.OperandResolver; | |||||
import org.apache.poi.ss.formula.eval.ValueEval; | import org.apache.poi.ss.formula.eval.ValueEval; | ||||
/** | /** | ||||
public ValueEval getResult() { | public ValueEval getResult() { | ||||
if(result == null) { | if(result == null) { | ||||
return ErrorEval.VALUE_INVALID; | return ErrorEval.VALUE_INVALID; | ||||
} else { | |||||
return result; | |||||
} | |||||
} else if(result instanceof BlankEval) { | |||||
return ErrorEval.VALUE_INVALID; | |||||
} else | |||||
try { | |||||
if(OperandResolver.coerceValueToString(OperandResolver.getSingleValue(result, 0, 0)).equals("")) { | |||||
return ErrorEval.VALUE_INVALID; | |||||
} | |||||
else { | |||||
return result; | |||||
} | |||||
} catch (EvaluationException e) { | |||||
return e.getErrorEval(); | |||||
} | |||||
} | } | ||||
} | } |
package org.apache.poi.ss.formula.functions; | package org.apache.poi.ss.formula.functions; | ||||
import org.apache.poi.ss.formula.TwoDEval; | |||||
import org.apache.poi.ss.formula.eval.AreaEval; | |||||
import org.apache.poi.ss.formula.eval.BlankEval; | import org.apache.poi.ss.formula.eval.BlankEval; | ||||
import org.apache.poi.ss.formula.eval.ErrorEval; | import org.apache.poi.ss.formula.eval.ErrorEval; | ||||
import org.apache.poi.ss.formula.eval.EvaluationException; | import org.apache.poi.ss.formula.eval.EvaluationException; | ||||
import org.apache.poi.ss.formula.eval.NotImplementedException; | import org.apache.poi.ss.formula.eval.NotImplementedException; | ||||
import org.apache.poi.ss.formula.eval.NumericValueEval; | import org.apache.poi.ss.formula.eval.NumericValueEval; | ||||
import org.apache.poi.ss.formula.eval.RefEval; | |||||
import org.apache.poi.ss.formula.eval.OperandResolver; | |||||
import org.apache.poi.ss.formula.eval.StringEval; | import org.apache.poi.ss.formula.eval.StringEval; | ||||
import org.apache.poi.ss.formula.eval.StringValueEval; | import org.apache.poi.ss.formula.eval.StringValueEval; | ||||
import org.apache.poi.ss.formula.eval.ValueEval; | import org.apache.poi.ss.formula.eval.ValueEval; | ||||
public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, | public ValueEval evaluate(int srcRowIndex, int srcColumnIndex, | ||||
ValueEval database, ValueEval filterColumn, ValueEval conditionDatabase) { | ValueEval database, ValueEval filterColumn, ValueEval conditionDatabase) { | ||||
// Input processing and error checks. | // Input processing and error checks. | ||||
if(!(database instanceof TwoDEval) || !(conditionDatabase instanceof TwoDEval)) { | |||||
if(!(database instanceof AreaEval) || !(conditionDatabase instanceof AreaEval)) { | |||||
return ErrorEval.VALUE_INVALID; | return ErrorEval.VALUE_INVALID; | ||||
} | } | ||||
TwoDEval db = (TwoDEval)database; | |||||
TwoDEval cdb = (TwoDEval)conditionDatabase; | |||||
AreaEval db = (AreaEval)database; | |||||
AreaEval cdb = (AreaEval)conditionDatabase; | |||||
try { | |||||
filterColumn = OperandResolver.getSingleValue(filterColumn, srcRowIndex, srcColumnIndex); | |||||
} catch (EvaluationException e) { | |||||
return e.getErrorEval(); | |||||
} | |||||
int fc; | int fc; | ||||
try { | try { | ||||
} | } | ||||
// Filter each entry. | // Filter each entry. | ||||
if(matches) { | if(matches) { | ||||
try { | |||||
ValueEval currentValueEval = solveReference(db.getValue(row, fc)); | |||||
// Pass the match to the algorithm and conditionally abort the search. | |||||
boolean shouldContinue = algorithm.processMatch(currentValueEval); | |||||
if(! shouldContinue) { | |||||
break; | |||||
} | |||||
} catch (EvaluationException e) { | |||||
return e.getErrorEval(); | |||||
ValueEval currentValueEval = resolveReference(db, row, fc); | |||||
// Pass the match to the algorithm and conditionally abort the search. | |||||
boolean shouldContinue = algorithm.processMatch(currentValueEval); | |||||
if(! shouldContinue) { | |||||
break; | |||||
} | } | ||||
} | } | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Resolve reference(-chains) until we have a normal value. | |||||
* | |||||
* | * | ||||
* @param field a ValueEval which can be a RefEval. | |||||
* @return a ValueEval which is guaranteed not to be a RefEval | |||||
* @throws EvaluationException If a multi-sheet reference was found along the way. | |||||
*/ | |||||
private static ValueEval solveReference(ValueEval field) throws EvaluationException { | |||||
if (field instanceof RefEval) { | |||||
RefEval refEval = (RefEval)field; | |||||
if (refEval.getNumberOfSheets() > 1) { | |||||
throw new EvaluationException(ErrorEval.VALUE_INVALID); | |||||
} | |||||
return solveReference(refEval.getInnerValueEval(refEval.getFirstSheetIndex())); | |||||
} | |||||
else { | |||||
return field; | |||||
} | |||||
} | |||||
/** | |||||
* Returns the first column index that matches the given name. The name can either be | |||||
* a string or an integer, when it's an integer, then the respective column | |||||
* (1 based index) is returned. | |||||
* @param nameValueEval | |||||
* @param db | |||||
* @return the first column index that matches the given name (or int) | |||||
* @param nameValueEval Must not be a RefEval or AreaEval. Thus make sure resolveReference() is called on the value first! | |||||
* @param db Database | |||||
* @return Corresponding column number. | |||||
* @throws EvaluationException | * @throws EvaluationException | ||||
*/ | */ | ||||
@SuppressWarnings("unused") | |||||
private static int getColumnForTag(ValueEval nameValueEval, TwoDEval db) | |||||
private static int getColumnForName(ValueEval nameValueEval, AreaEval db) | |||||
throws EvaluationException { | throws EvaluationException { | ||||
int resultColumn = -1; | |||||
// Numbers as column indicator are allowed, check that. | |||||
if(nameValueEval instanceof NumericValueEval) { | |||||
double doubleResultColumn = ((NumericValueEval)nameValueEval).getNumberValue(); | |||||
resultColumn = (int)doubleResultColumn; | |||||
// Floating comparisions are usually not possible, but should work for 0.0. | |||||
if(doubleResultColumn - resultColumn != 0.0) | |||||
throw new EvaluationException(ErrorEval.VALUE_INVALID); | |||||
resultColumn -= 1; // Numbers are 1-based not 0-based. | |||||
} else { | |||||
resultColumn = getColumnForName(nameValueEval, db); | |||||
} | |||||
return resultColumn; | |||||
} | |||||
private static int getColumnForName(ValueEval nameValueEval, TwoDEval db) | |||||
throws EvaluationException { | |||||
String name = getStringFromValueEval(nameValueEval); | |||||
String name = OperandResolver.coerceValueToString(nameValueEval); | |||||
return getColumnForString(db, name); | return getColumnForString(db, name); | ||||
} | } | ||||
* @return Corresponding column number. | * @return Corresponding column number. | ||||
* @throws EvaluationException If it's not possible to turn all headings into strings. | * @throws EvaluationException If it's not possible to turn all headings into strings. | ||||
*/ | */ | ||||
private static int getColumnForString(TwoDEval db,String name) | |||||
private static int getColumnForString(AreaEval db,String name) | |||||
throws EvaluationException { | throws EvaluationException { | ||||
int resultColumn = -1; | int resultColumn = -1; | ||||
final int width = db.getWidth(); | final int width = db.getWidth(); | ||||
for(int column = 0; column < width; ++column) { | for(int column = 0; column < width; ++column) { | ||||
ValueEval columnNameValueEval = db.getValue(0, column); | |||||
if(solveReference(columnNameValueEval) instanceof BlankEval) { | |||||
ValueEval columnNameValueEval = resolveReference(db, 0, column); | |||||
if(columnNameValueEval instanceof BlankEval) { | |||||
continue; | continue; | ||||
} | } | ||||
String columnName = getStringFromValueEval(columnNameValueEval); | |||||
if(columnNameValueEval instanceof ErrorEval) { | |||||
continue; | |||||
} | |||||
String columnName = OperandResolver.coerceValueToString(columnNameValueEval); | |||||
if(name.equals(columnName)) { | if(name.equals(columnName)) { | ||||
resultColumn = column; | resultColumn = column; | ||||
break; | break; | ||||
* @throws EvaluationException If references could not be resolved or comparison | * @throws EvaluationException If references could not be resolved or comparison | ||||
* operators and operands didn't match. | * operators and operands didn't match. | ||||
*/ | */ | ||||
private static boolean fullfillsConditions(TwoDEval db, int row, TwoDEval cdb) | |||||
private static boolean fullfillsConditions(AreaEval db, int row, AreaEval cdb) | |||||
throws EvaluationException { | throws EvaluationException { | ||||
// Only one row must match to accept the input, so rows are ORed. | // Only one row must match to accept the input, so rows are ORed. | ||||
// Each row is made up of cells where each cell is a condition, | // Each row is made up of cells where each cell is a condition, | ||||
// special column that accepts formulas. | // special column that accepts formulas. | ||||
boolean columnCondition = true; | boolean columnCondition = true; | ||||
ValueEval condition = null; | ValueEval condition = null; | ||||
try { | |||||
// The condition to apply. | |||||
condition = solveReference(cdb.getValue(conditionRow, column)); | |||||
} catch (java.lang.RuntimeException e) { | |||||
// It might be a special formula, then it is ok if it fails. | |||||
columnCondition = false; | |||||
} | |||||
// The condition to apply. | |||||
condition = resolveReference(cdb, conditionRow, column); | |||||
// If the condition is empty it matches. | // If the condition is empty it matches. | ||||
if(condition instanceof BlankEval) | if(condition instanceof BlankEval) | ||||
continue; | continue; | ||||
// The column in the DB to apply the condition to. | // The column in the DB to apply the condition to. | ||||
ValueEval targetHeader = solveReference(cdb.getValue(0, column)); | |||||
targetHeader = solveReference(targetHeader); | |||||
ValueEval targetHeader = resolveReference(cdb, 0, column); | |||||
if(!(targetHeader instanceof StringValueEval)) { | if(!(targetHeader instanceof StringValueEval)) { | ||||
throw new EvaluationException(ErrorEval.VALUE_INVALID); | throw new EvaluationException(ErrorEval.VALUE_INVALID); | ||||
if(columnCondition == true) { // normal column condition | if(columnCondition == true) { // normal column condition | ||||
// Should not throw, checked above. | // Should not throw, checked above. | ||||
ValueEval value = db.getValue( | |||||
row, getColumnForName(targetHeader, db)); | |||||
ValueEval value = resolveReference(db, row, getColumnForName(targetHeader, db)); | |||||
if(!testNormalCondition(value, condition)) { | if(!testNormalCondition(value, condition)) { | ||||
matches = false; | matches = false; | ||||
break; | break; | ||||
} | } | ||||
} else { // It's a special formula condition. | } else { // It's a special formula condition. | ||||
if(getStringFromValueEval(condition).isEmpty()) { | |||||
// TODO: Check whether the condition cell contains a formula and return #VALUE! if it doesn't. | |||||
if(OperandResolver.coerceValueToString(condition).isEmpty()) { | |||||
throw new EvaluationException(ErrorEval.VALUE_INVALID); | throw new EvaluationException(ErrorEval.VALUE_INVALID); | ||||
} | } | ||||
throw new NotImplementedException( | throw new NotImplementedException( | ||||
if(itsANumber) { | if(itsANumber) { | ||||
return testNumericCondition(value, operator.equal, stringOrNumber); | return testNumericCondition(value, operator.equal, stringOrNumber); | ||||
} else { // It's a string. | } else { // It's a string. | ||||
String valueString = value instanceof BlankEval ? "" : getStringFromValueEval(value); | |||||
String valueString = value instanceof BlankEval ? "" : OperandResolver.coerceValueToString(value); | |||||
return stringOrNumber.equals(valueString); | return stringOrNumber.equals(valueString); | ||||
} | } | ||||
} else { // It's a text starts-with condition. | } else { // It's a text starts-with condition. | ||||
return value instanceof StringEval; | return value instanceof StringEval; | ||||
} | } | ||||
else { | else { | ||||
String valueString = value instanceof BlankEval ? "" : getStringFromValueEval(value); | |||||
String valueString = value instanceof BlankEval ? "" : OperandResolver.coerceValueToString(value); | |||||
return valueString.startsWith(conditionString); | return valueString.startsWith(conditionString); | ||||
} | } | ||||
} | } | ||||
return null; | return null; | ||||
} | } | ||||
} | } | ||||
/** | /** | ||||
* Takes a ValueEval and tries to retrieve a String value from it. | |||||
* It tries to resolve references if there are any. | |||||
* Resolve a ValueEval that's in an AreaEval. | |||||
* | * | ||||
* @param value ValueEval to retrieve the string from. | |||||
* @return String corresponding to the given ValueEval. | |||||
* @throws EvaluationException If it's not possible to retrieve a String value. | |||||
* @param db AreaEval from which the cell to resolve is retrieved. | |||||
* @param dbRow Relative row in the AreaEval. | |||||
* @param dbCol Relative column in the AreaEval. | |||||
* @return A ValueEval that is a NumberEval, StringEval, BoolEval, BlankEval or ErrorEval. | |||||
*/ | */ | ||||
private static String getStringFromValueEval(ValueEval value) | |||||
throws EvaluationException { | |||||
value = solveReference(value); | |||||
if(!(value instanceof StringValueEval)) | |||||
throw new EvaluationException(ErrorEval.VALUE_INVALID); | |||||
return ((StringValueEval)value).getStringValue(); | |||||
private static ValueEval resolveReference(AreaEval db, int dbRow, int dbCol) { | |||||
try { | |||||
return OperandResolver.getSingleValue(db.getValue(dbRow, dbCol), db.getFirstRow()+dbRow, db.getFirstColumn()+dbCol); | |||||
} catch (EvaluationException e) { | |||||
return e.getErrorEval(); | |||||
} | |||||
} | } | ||||
} | } |
package org.apache.poi.ss.usermodel; | package org.apache.poi.ss.usermodel; | ||||
import org.apache.poi.util.Removal; | |||||
/** | /** | ||||
* High level representation for Border Formatting component | * High level representation for Border Formatting component | ||||
* of Conditional Formatting settings | * of Conditional Formatting settings | ||||
/** No border | /** No border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#NONE} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#NONE} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_NONE = 0x0; | short BORDER_NONE = 0x0; | ||||
/** Thin border | /** Thin border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#THIN} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#THIN} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_THIN = 0x1; | short BORDER_THIN = 0x1; | ||||
/** Medium border | /** Medium border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_MEDIUM = 0x2; | short BORDER_MEDIUM = 0x2; | ||||
/** dash border | /** dash border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DASHED} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#DASHED} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_DASHED = 0x3; | short BORDER_DASHED = 0x3; | ||||
/** dot border | /** dot border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DOTTED} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#DOTTED} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_DOTTED = 0x4; | short BORDER_DOTTED = 0x4; | ||||
/** Thick border | /** Thick border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#THICK} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#THICK} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_THICK = 0x5; | short BORDER_THICK = 0x5; | ||||
/** double-line border | /** double-line border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DOUBLE} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#DOUBLE} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_DOUBLE = 0x6; | short BORDER_DOUBLE = 0x6; | ||||
/** hair-line border | /** hair-line border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#HAIR} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#HAIR} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_HAIR = 0x7; | short BORDER_HAIR = 0x7; | ||||
/** Medium dashed border | /** Medium dashed border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASHED} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASHED} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_MEDIUM_DASHED = 0x8; | short BORDER_MEDIUM_DASHED = 0x8; | ||||
/** dash-dot border | /** dash-dot border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_DASH_DOT = 0x9; | short BORDER_DASH_DOT = 0x9; | ||||
/** medium dash-dot border | /** medium dash-dot border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_MEDIUM_DASH_DOT = 0xA; | short BORDER_MEDIUM_DASH_DOT = 0xA; | ||||
/** dash-dot-dot border | /** dash-dot-dot border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT_DOT} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT_DOT} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_DASH_DOT_DOT = 0xB; | short BORDER_DASH_DOT_DOT = 0xB; | ||||
/** medium dash-dot-dot border | /** medium dash-dot-dot border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT_DOT} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT_DOT} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_MEDIUM_DASH_DOT_DOT = 0xC; | short BORDER_MEDIUM_DASH_DOT_DOT = 0xC; | ||||
/** slanted dash-dot border | /** slanted dash-dot border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#SLANTED_DASH_DOT} | * @deprecated 3.15 beta 2. Use {@link BorderStyle#SLANTED_DASH_DOT} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
short BORDER_SLANTED_DASH_DOT = 0xD; | short BORDER_SLANTED_DASH_DOT = 0xD; | ||||
BorderStyle getBorderBottom(); | |||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderBottomEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
short getBorderBottom(); | |||||
/** @since POI 3.15 */ | |||||
BorderStyle getBorderBottomEnum(); | |||||
BorderStyle getBorderDiagonal(); | |||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderDiagonalEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
short getBorderDiagonal(); | |||||
/** @since POI 3.15 */ | |||||
BorderStyle getBorderDiagonalEnum(); | |||||
BorderStyle getBorderLeft(); | |||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderLeftEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
short getBorderLeft(); | |||||
/** @since POI 3.15 */ | |||||
BorderStyle getBorderLeftEnum(); | |||||
BorderStyle getBorderRight(); | |||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderRightEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
short getBorderRight(); | |||||
/** @since POI 3.15 */ | |||||
BorderStyle getBorderRightEnum(); | |||||
BorderStyle getBorderTop(); | |||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderTopEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
short getBorderTop(); | |||||
/** @since POI 3.15 */ | |||||
BorderStyle getBorderTopEnum(); | |||||
short getBottomBorderColor(); | short getBottomBorderColor(); | ||||
Color getBottomBorderColorColor(); | Color getBottomBorderColorColor(); | ||||
"#,##0.00", | "#,##0.00", | ||||
"\"$\"#,##0_);(\"$\"#,##0)", | "\"$\"#,##0_);(\"$\"#,##0)", | ||||
"\"$\"#,##0_);[Red](\"$\"#,##0)", | "\"$\"#,##0_);[Red](\"$\"#,##0)", | ||||
"\"$\"#,##,00_);(\"$\"#,##0.00)", | |||||
"\"$\"#,##0.00_);(\"$\"#,##0.00)", | |||||
"\"$\"#,##0.00_);[Red](\"$\"#,##0.00)", | "\"$\"#,##0.00_);[Red](\"$\"#,##0.00)", | ||||
"0%", | "0%", | ||||
"0.00%", | "0.00%", |
import org.apache.poi.ss.util.CellAddress; | import org.apache.poi.ss.util.CellAddress; | ||||
import org.apache.poi.ss.util.CellRangeAddress; | import org.apache.poi.ss.util.CellRangeAddress; | ||||
import org.apache.poi.util.Internal; | import org.apache.poi.util.Internal; | ||||
import org.apache.poi.util.Removal; | |||||
/** | /** | ||||
* High level representation of a cell in a row of a spreadsheet. | * High level representation of a cell in a row of a spreadsheet. | ||||
* @see #getCellType() | * @see #getCellType() | ||||
* @deprecated POI 3.15 beta 3. Use {@link CellType#NUMERIC} instead. | * @deprecated POI 3.15 beta 3. Use {@link CellType#NUMERIC} instead. | ||||
*/ | */ | ||||
CellType CELL_TYPE_NUMERIC = CellType.NUMERIC; | |||||
@Removal(version="4.0") | |||||
int CELL_TYPE_NUMERIC = 0; //CellType.NUMERIC.getCode(); | |||||
/** | /** | ||||
* String Cell type (1) | * String Cell type (1) | ||||
* @see #getCellType() | * @see #getCellType() | ||||
* @deprecated POI 3.15 beta 3. Use {@link CellType#STRING} instead. | * @deprecated POI 3.15 beta 3. Use {@link CellType#STRING} instead. | ||||
*/ | */ | ||||
CellType CELL_TYPE_STRING = CellType.STRING; | |||||
@Removal(version="4.0") | |||||
int CELL_TYPE_STRING = 1; //CellType.STRING.getCode(); | |||||
/** | /** | ||||
* Formula Cell type (2) | * Formula Cell type (2) | ||||
* @see #getCellType() | * @see #getCellType() | ||||
* @deprecated POI 3.15 beta 3. Use {@link CellType#FORMULA} instead. | * @deprecated POI 3.15 beta 3. Use {@link CellType#FORMULA} instead. | ||||
*/ | */ | ||||
CellType CELL_TYPE_FORMULA = CellType.FORMULA; | |||||
@Removal(version="4.0") | |||||
int CELL_TYPE_FORMULA = 2; //CellType.FORMULA.getCode(); | |||||
/** | /** | ||||
* Blank Cell type (3) | * Blank Cell type (3) | ||||
* @see #getCellType() | * @see #getCellType() | ||||
* @deprecated POI 3.15 beta 3. Use {@link CellType#BLANK} instead. | * @deprecated POI 3.15 beta 3. Use {@link CellType#BLANK} instead. | ||||
*/ | */ | ||||
CellType CELL_TYPE_BLANK = CellType.BLANK; | |||||
@Removal(version="4.0") | |||||
int CELL_TYPE_BLANK = 3; //CellType.BLANK.getCode(); | |||||
/** | /** | ||||
* Boolean Cell type (4) | * Boolean Cell type (4) | ||||
* @see #getCellType() | * @see #getCellType() | ||||
* @deprecated POI 3.15 beta 3. Use {@link CellType#BOOLEAN} instead. | * @deprecated POI 3.15 beta 3. Use {@link CellType#BOOLEAN} instead. | ||||
*/ | */ | ||||
CellType CELL_TYPE_BOOLEAN = CellType.BOOLEAN; | |||||
@Removal(version="4.0") | |||||
int CELL_TYPE_BOOLEAN = 4; //CellType.BOOLEAN.getCode(); | |||||
/** | /** | ||||
* Error Cell type (5) | * Error Cell type (5) | ||||
* @see #getCellType() | * @see #getCellType() | ||||
* @deprecated POI 3.15 beta 3. Use {@link CellType#ERROR} instead. | * @deprecated POI 3.15 beta 3. Use {@link CellType#ERROR} instead. | ||||
*/ | */ | ||||
CellType CELL_TYPE_ERROR = CellType.ERROR; | |||||
@Removal(version="4.0") | |||||
int CELL_TYPE_ERROR = 5; //CellType.ERROR.getCode(); | |||||
/** | /** | ||||
* Returns column index of this cell | * Returns column index of this cell | ||||
* @see CellType#ERROR | * @see CellType#ERROR | ||||
* @deprecated POI 3.15 beta 3. Use {@link #setCellType(CellType)} instead. | * @deprecated POI 3.15 beta 3. Use {@link #setCellType(CellType)} instead. | ||||
*/ | */ | ||||
@Removal(version="4.0") | |||||
void setCellType(int cellType); | void setCellType(int cellType); | ||||
/** | /** | ||||
* Set the cells type (numeric, formula or string). | * Set the cells type (numeric, formula or string). | ||||
/** | /** | ||||
* Return the cell type. | * Return the cell type. | ||||
* | * | ||||
* Will return {@link CellType} in a future version of POI. | |||||
* Will return {@link CellType} in version 4.0 of POI. | |||||
* For forwards compatibility, do not hard-code cell type literals in your code. | * For forwards compatibility, do not hard-code cell type literals in your code. | ||||
* | * | ||||
* @return the cell type | * @return the cell type | ||||
* @deprecated POI 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
int getCellType(); | int getCellType(); | ||||
* @return the cell type | * @return the cell type | ||||
* @since POI 3.15 beta 3 | * @since POI 3.15 beta 3 | ||||
* @deprecated 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 be renamed to <code>getCellType()</code> when we make the CellType enum transition in POI 4.0. See bug 59791. | |||||
*/ | */ | ||||
@Internal(since="POI 3.15 beta 3") | |||||
@Removal(version="4.2") | |||||
CellType getCellTypeEnum(); | CellType getCellTypeEnum(); | ||||
/** | /** | ||||
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, | * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, | ||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending | * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending | ||||
* on the cached value of the formula | * on the cached value of the formula | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
int getCachedFormulaResultType(); | int getCachedFormulaResultType(); | ||||
* on the cached value of the formula | * on the cached value of the formula | ||||
* @since POI 3.15 beta 3 | * @since POI 3.15 beta 3 | ||||
* @deprecated 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 be renamed to <code>getCachedFormulaResultType()</code> when we make the CellType enum transition in POI 4.0. See bug 59791. | |||||
*/ | */ | ||||
@Internal(since="POI 3.15 beta 3") | |||||
CellType getCachedFormulaResultTypeEnum(); | CellType getCachedFormulaResultTypeEnum(); | ||||
/** | /** |
package org.apache.poi.ss.usermodel; | package org.apache.poi.ss.usermodel; | ||||
import org.apache.poi.util.Removal; | |||||
public interface CellStyle { | public interface CellStyle { | ||||
/** | /** | ||||
* general (normal) horizontal alignment | * general (normal) horizontal alignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#GENERAL} instead. | * @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#GENERAL} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short ALIGN_GENERAL = 0x0; //HorizontalAlignment.GENERAL.getCode(); | static final short ALIGN_GENERAL = 0x0; //HorizontalAlignment.GENERAL.getCode(); | ||||
/** | /** | ||||
* left-justified horizontal alignment | * left-justified horizontal alignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#LEFT} instead. | * @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#LEFT} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short ALIGN_LEFT = 0x1; //HorizontalAlignment.LEFT.getCode(); | static final short ALIGN_LEFT = 0x1; //HorizontalAlignment.LEFT.getCode(); | ||||
/** | /** | ||||
* center horizontal alignment | * center horizontal alignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#CENTER} instead. | * @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#CENTER} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short ALIGN_CENTER = 0x2; //HorizontalAlignment.CENTER.getCode(); | static final short ALIGN_CENTER = 0x2; //HorizontalAlignment.CENTER.getCode(); | ||||
/** | /** | ||||
* right-justified horizontal alignment | * right-justified horizontal alignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#RIGHT} instead. | * @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#RIGHT} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short ALIGN_RIGHT = 0x3; //HorizontalAlignment.RIGHT.getCode(); | static final short ALIGN_RIGHT = 0x3; //HorizontalAlignment.RIGHT.getCode(); | ||||
/** | /** | ||||
* fill? horizontal alignment | * fill? horizontal alignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#FILL} instead. | * @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#FILL} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short ALIGN_FILL = 0x4; //HorizontalAlignment.FILL.getCode(); | static final short ALIGN_FILL = 0x4; //HorizontalAlignment.FILL.getCode(); | ||||
/** | /** | ||||
* justified horizontal alignment | * justified horizontal alignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#JUSTIFY} instead. | * @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#JUSTIFY} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short ALIGN_JUSTIFY = 0x5; //HorizontalAlignment.JUSTIFY.getCode(); | static final short ALIGN_JUSTIFY = 0x5; //HorizontalAlignment.JUSTIFY.getCode(); | ||||
/** | /** | ||||
* center-selection? horizontal alignment | * center-selection? horizontal alignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#CENTER_SELECTION} instead. | * @deprecated POI 3.15 beta 3. Use {@link HorizontalAlignment#CENTER_SELECTION} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short ALIGN_CENTER_SELECTION = 0x6; //HorizontalAlignment.CENTER_SELECTION.getCode(); | static final short ALIGN_CENTER_SELECTION = 0x6; //HorizontalAlignment.CENTER_SELECTION.getCode(); | ||||
/** | /** | ||||
* top-aligned vertical alignment | * top-aligned vertical alignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link VerticalAlignment#TOP} instead. | * @deprecated POI 3.15 beta 3. Use {@link VerticalAlignment#TOP} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short VERTICAL_TOP = 0x0; //VerticalAlignment.TOP.getCode(); | static final short VERTICAL_TOP = 0x0; //VerticalAlignment.TOP.getCode(); | ||||
/** | /** | ||||
* center-aligned vertical alignment | * center-aligned vertical alignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link VerticalAlignment#CENTER} instead. | * @deprecated POI 3.15 beta 3. Use {@link VerticalAlignment#CENTER} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short VERTICAL_CENTER = 0x1; //VerticalAlignment.CENTER.getCode(); | static final short VERTICAL_CENTER = 0x1; //VerticalAlignment.CENTER.getCode(); | ||||
/** | /** | ||||
* bottom-aligned vertical alignment | * bottom-aligned vertical alignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link VerticalAlignment#BOTTOM} instead. | * @deprecated POI 3.15 beta 3. Use {@link VerticalAlignment#BOTTOM} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short VERTICAL_BOTTOM = 0x2; //VerticalAlignment.BOTTOM.getCode(); | static final short VERTICAL_BOTTOM = 0x2; //VerticalAlignment.BOTTOM.getCode(); | ||||
/** | /** | ||||
* vertically justified vertical alignment | * vertically justified vertical alignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link VerticalAlignment#JUSTIFY} instead. | * @deprecated POI 3.15 beta 3. Use {@link VerticalAlignment#JUSTIFY} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short VERTICAL_JUSTIFY = 0x3; //VerticalAlignment.JUSTIFY.getCode(); | static final short VERTICAL_JUSTIFY = 0x3; //VerticalAlignment.JUSTIFY.getCode(); | ||||
/** | /** | ||||
* No border | * No border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#NONE} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#NONE} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_NONE = 0x0; //BorderStyle.NONE.getCode(); | static final short BORDER_NONE = 0x0; //BorderStyle.NONE.getCode(); | ||||
/** | /** | ||||
* Thin border | * Thin border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#THIN} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#THIN} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_THIN = 0x1; //BorderStyle.THIN.getCode(); | static final short BORDER_THIN = 0x1; //BorderStyle.THIN.getCode(); | ||||
/** | /** | ||||
* Medium border | * Medium border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_MEDIUM = 0x2; //BorderStyle.MEDIUM.getCode(); | static final short BORDER_MEDIUM = 0x2; //BorderStyle.MEDIUM.getCode(); | ||||
/** | /** | ||||
* dash border | * dash border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DASHED} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#DASHED} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_DASHED = 0x3; //BorderStyle.DASHED.getCode(); | static final short BORDER_DASHED = 0x3; //BorderStyle.DASHED.getCode(); | ||||
/** | /** | ||||
* dot border | * dot border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DOTTED} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#DOTTED} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_DOTTED = 0x4; //BorderStyle.DOTTED.getCode(); | static final short BORDER_DOTTED = 0x4; //BorderStyle.DOTTED.getCode(); | ||||
/** | /** | ||||
* Thick border | * Thick border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#THICK} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#THICK} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_THICK = 0x5; //BorderStyle.THICK.getCode(); | static final short BORDER_THICK = 0x5; //BorderStyle.THICK.getCode(); | ||||
/** | /** | ||||
* double-line border | * double-line border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DOUBLE} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#DOUBLE} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_DOUBLE = 0x6; //BorderStyle.DOUBLE.getCode(); | static final short BORDER_DOUBLE = 0x6; //BorderStyle.DOUBLE.getCode(); | ||||
/** | /** | ||||
* hair-line border | * hair-line border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#HAIR} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#HAIR} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_HAIR = 0x7; //BorderStyle.HAIR.getCode(); | static final short BORDER_HAIR = 0x7; //BorderStyle.HAIR.getCode(); | ||||
/** | /** | ||||
* Medium dashed border | * Medium dashed border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASHED} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASHED} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_MEDIUM_DASHED = 0x8; //BorderStyle.MEDIUM_DASHED.getCode(); | static final short BORDER_MEDIUM_DASHED = 0x8; //BorderStyle.MEDIUM_DASHED.getCode(); | ||||
/** | /** | ||||
* dash-dot border | * dash-dot border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_DASH_DOT = 0x9; //BorderStyle.DASH_DOT.getCode(); | static final short BORDER_DASH_DOT = 0x9; //BorderStyle.DASH_DOT.getCode(); | ||||
/** | /** | ||||
* medium dash-dot border | * medium dash-dot border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_MEDIUM_DASH_DOT = 0xA; //BorderStyle.MEDIUM_DASH_DOT.getCode(); | static final short BORDER_MEDIUM_DASH_DOT = 0xA; //BorderStyle.MEDIUM_DASH_DOT.getCode(); | ||||
/** | /** | ||||
* dash-dot-dot border | * dash-dot-dot border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT_DOT} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#DASH_DOT_DOT} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_DASH_DOT_DOT = 0xB; //BorderStyle.DASH_DOT_DOT.getCode(); | static final short BORDER_DASH_DOT_DOT = 0xB; //BorderStyle.DASH_DOT_DOT.getCode(); | ||||
/** | /** | ||||
* medium dash-dot-dot border | * medium dash-dot-dot border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT_DOT} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#MEDIUM_DASH_DOT_DOT} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_MEDIUM_DASH_DOT_DOT = 0xC; //BorderStyle.MEDIUM_DASH_DOT_DOT.getCode(); | static final short BORDER_MEDIUM_DASH_DOT_DOT = 0xC; //BorderStyle.MEDIUM_DASH_DOT_DOT.getCode(); | ||||
/** | /** | ||||
* slanted dash-dot border | * slanted dash-dot border | ||||
* @deprecated 3.15 beta 2. Use {@link BorderStyle#SLANTED_DASH_DOT} instead. | * @deprecated 3.15 beta 2. Use {@link BorderStyle#SLANTED_DASH_DOT} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BORDER_SLANTED_DASH_DOT = 0xD; //BorderStyle.SLANTED_DASH_DOT.getCode(); | static final short BORDER_SLANTED_DASH_DOT = 0xD; //BorderStyle.SLANTED_DASH_DOT.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: No background | * Fill Pattern: No background | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#NO_FILL} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#NO_FILL} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short NO_FILL = 0; //FillPatternType.NO_FILL.getCode(); | static final short NO_FILL = 0; //FillPatternType.NO_FILL.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Solidly filled | * Fill Pattern: Solidly filled | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#SOLID_FOREGROUND} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#SOLID_FOREGROUND} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short SOLID_FOREGROUND = 1; //FillPatternType.SOLID_FOREGROUND.getCode(); | static final short SOLID_FOREGROUND = 1; //FillPatternType.SOLID_FOREGROUND.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Small fine dots | * Fill Pattern: Small fine dots | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#FINE_DOTS} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#FINE_DOTS} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short FINE_DOTS = 2; //FillPatternType.FINE_DOTS.getCode(); | static final short FINE_DOTS = 2; //FillPatternType.FINE_DOTS.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Wide dots | * Fill Pattern: Wide dots | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#ALT_BARS} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#ALT_BARS} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short ALT_BARS = 3; //FillPatternType.ALT_BARS.getCode(); | static final short ALT_BARS = 3; //FillPatternType.ALT_BARS.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Sparse dots | * Fill Pattern: Sparse dots | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#SPARSE_DOTS} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#SPARSE_DOTS} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short SPARSE_DOTS = 4; //FillPatternType.SPARSE_DOTS.getCode(); | static final short SPARSE_DOTS = 4; //FillPatternType.SPARSE_DOTS.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Thick horizontal bands | * Fill Pattern: Thick horizontal bands | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_HORZ_BANDS} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_HORZ_BANDS} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short THICK_HORZ_BANDS = 5; //FillPatternType.THICK_HORZ_BANDS.getCode(); | static final short THICK_HORZ_BANDS = 5; //FillPatternType.THICK_HORZ_BANDS.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Thick vertical bands | * Fill Pattern: Thick vertical bands | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_VERT_BANDS} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_VERT_BANDS} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short THICK_VERT_BANDS = 6; //FillPatternType.THICK_VERT_BANDS.getCode(); | static final short THICK_VERT_BANDS = 6; //FillPatternType.THICK_VERT_BANDS.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Thick backward facing diagonals | * Fill Pattern: Thick backward facing diagonals | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_BACKWARD_DIAG} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_BACKWARD_DIAG} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short THICK_BACKWARD_DIAG = 7; //FillPatternType.THICK_BACKWARD_DIAG.getCode(); | static final short THICK_BACKWARD_DIAG = 7; //FillPatternType.THICK_BACKWARD_DIAG.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Thick forward facing diagonals | * Fill Pattern: Thick forward facing diagonals | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_FORWARD_DIAG} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#THICK_FORWARD_DIAG} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short THICK_FORWARD_DIAG = 8; //FillPatternType.THICK_FORWARD_DIAG.getCode(); | static final short THICK_FORWARD_DIAG = 8; //FillPatternType.THICK_FORWARD_DIAG.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Large spots | * Fill Pattern: Large spots | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#BIG_SPOTS} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#BIG_SPOTS} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BIG_SPOTS = 9; //FillPatternType.BIG_SPOTS.getCode(); | static final short BIG_SPOTS = 9; //FillPatternType.BIG_SPOTS.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Brick-like layout | * Fill Pattern: Brick-like layout | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#BRICKS} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#BRICKS} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short BRICKS = 10; //FillPatternType.BRICKS.getCode(); | static final short BRICKS = 10; //FillPatternType.BRICKS.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Thin horizontal bands | * Fill Pattern: Thin horizontal bands | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_HORZ_BANDS} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_HORZ_BANDS} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short THIN_HORZ_BANDS = 11; //FillPatternType.THIN_HORZ_BANDS.getCode(); | static final short THIN_HORZ_BANDS = 11; //FillPatternType.THIN_HORZ_BANDS.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Thin vertical bands | * Fill Pattern: Thin vertical bands | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_VERT_BANDS} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_VERT_BANDS} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short THIN_VERT_BANDS = 12; //FillPatternType.THIN_VERT_BANDS.getCode(); | static final short THIN_VERT_BANDS = 12; //FillPatternType.THIN_VERT_BANDS.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Thin backward diagonal | * Fill Pattern: Thin backward diagonal | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_BACKWARD_DIAG} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_BACKWARD_DIAG} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short THIN_BACKWARD_DIAG = 13; //FillPatternType.THIN_BACKWARD_DIAG.getCode(); | static final short THIN_BACKWARD_DIAG = 13; //FillPatternType.THIN_BACKWARD_DIAG.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Thin forward diagonal | * Fill Pattern: Thin forward diagonal | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_FORWARD_DIAG} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#THIN_FORWARD_DIAG} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short THIN_FORWARD_DIAG = 14; //FillPatternType.THIN_FORWARD_DIAG.getCode(); | static final short THIN_FORWARD_DIAG = 14; //FillPatternType.THIN_FORWARD_DIAG.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Squares | * Fill Pattern: Squares | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#SQUARES} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#SQUARES} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short SQUARES = 15; //FillPatternType.SQUARES.getCode(); | static final short SQUARES = 15; //FillPatternType.SQUARES.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Diamonds | * Fill Pattern: Diamonds | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#DIAMONDS} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#DIAMONDS} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short DIAMONDS = 16; //FillPatternType.DIAMONDS.getCode(); | static final short DIAMONDS = 16; //FillPatternType.DIAMONDS.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Less Dots | * Fill Pattern: Less Dots | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#LESS_DOTS} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#LESS_DOTS} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short LESS_DOTS = 17; //FillPatternType.LESS_DOTS.getCode(); | static final short LESS_DOTS = 17; //FillPatternType.LESS_DOTS.getCode(); | ||||
/** | /** | ||||
* Fill Pattern: Least Dots | * Fill Pattern: Least Dots | ||||
* @deprecated 3.15 beta 3. Use {@link FillPatternType#LEAST_DOTS} instead. | * @deprecated 3.15 beta 3. Use {@link FillPatternType#LEAST_DOTS} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
static final short LEAST_DOTS = 18; //FillPatternType.LEAST_DOTS.getCode(); | static final short LEAST_DOTS = 18; //FillPatternType.LEAST_DOTS.getCode(); | ||||
/** | /** | ||||
* @see #BORDER_SLANTED_DASH_DOT | * @see #BORDER_SLANTED_DASH_DOT | ||||
* @deprecated 3.15 beta 2. Use {@link #setBorderLeft(BorderStyle)} instead | * @deprecated 3.15 beta 2. Use {@link #setBorderLeft(BorderStyle)} instead | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
void setBorderLeft(short border); | void setBorderLeft(short border); | ||||
/** | /** | ||||
* set the type of border to use for the left border of the cell | * set the type of border to use for the left border of the cell | ||||
* @param border type | * @param border type | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
void setBorderLeft(BorderStyle border); | void setBorderLeft(BorderStyle border); | ||||
/** | /** | ||||
* get the type of border to use for the left border of the cell | * get the type of border to use for the left border of the cell | ||||
* @return border type | * @return border type | ||||
* @deprecated POI 3.15. Use {@link #getBorderLeftEnum()} instead. | |||||
* This will return a BorderStyle enum in the future. | |||||
*/ | |||||
short getBorderLeft(); | |||||
/** | |||||
* get the type of border to use for the left border of the cell | |||||
* @return border type | |||||
* @since POI 3.15 | |||||
*/ | */ | ||||
BorderStyle getBorderLeft(); | |||||
BorderStyle getBorderLeftEnum(); | |||||
/** | /** | ||||
* set the type of border to use for the right border of the cell | * set the type of border to use for the right border of the cell | ||||
* @see #BORDER_SLANTED_DASH_DOT | * @see #BORDER_SLANTED_DASH_DOT | ||||
* @deprecated 3.15 beta 2. Use {@link #setBorderRight(BorderStyle)} instead | * @deprecated 3.15 beta 2. Use {@link #setBorderRight(BorderStyle)} instead | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
void setBorderRight(short border); | void setBorderRight(short border); | ||||
/** | /** | ||||
* set the type of border to use for the right border of the cell | * set the type of border to use for the right border of the cell | ||||
* @param border type | * @param border type | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
void setBorderRight(BorderStyle border); | void setBorderRight(BorderStyle border); | ||||
/** | /** | ||||
* get the type of border to use for the right border of the cell | * get the type of border to use for the right border of the cell | ||||
* @return border type | * @return border type | ||||
* @deprecated POI 3.15. Use {@link #getBorderRightEnum()} instead. | |||||
* This will return a BorderStyle enum in the future. | |||||
*/ | |||||
short getBorderRight(); | |||||
/** | |||||
* get the type of border to use for the right border of the cell | |||||
* @return border type | |||||
* @since POI 3.15 | |||||
*/ | */ | ||||
BorderStyle getBorderRight(); | |||||
BorderStyle getBorderRightEnum(); | |||||
/** | /** | ||||
* set the type of border to use for the top border of the cell | * set the type of border to use for the top border of the cell | ||||
* @see #BORDER_SLANTED_DASH_DOT | * @see #BORDER_SLANTED_DASH_DOT | ||||
* @deprecated 3.15 beta 2. Use {@link #setBorderTop(BorderStyle)} instead | * @deprecated 3.15 beta 2. Use {@link #setBorderTop(BorderStyle)} instead | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
void setBorderTop(short border); | void setBorderTop(short border); | ||||
/** | /** | ||||
* set the type of border to use for the top border of the cell | * set the type of border to use for the top border of the cell | ||||
* @param border type | * @param border type | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
void setBorderTop(BorderStyle border); | void setBorderTop(BorderStyle border); | ||||
/** | /** | ||||
* get the type of border to use for the top border of the cell | * get the type of border to use for the top border of the cell | ||||
* @return border type | * @return border type | ||||
* @deprecated POI 3.15. Use {@link #getBorderTopEnum()} instead. | |||||
* This will return a BorderStyle enum in the future. | |||||
*/ | */ | ||||
BorderStyle getBorderTop(); | |||||
short getBorderTop(); | |||||
/** | |||||
* get the type of border to use for the top border of the cell | |||||
* @return border type | |||||
* @since POI 3.15 | |||||
*/ | |||||
BorderStyle getBorderTopEnum(); | |||||
/** | /** | ||||
* set the type of border to use for the bottom border of the cell | * set the type of border to use for the bottom border of the cell | ||||
* @see #BORDER_SLANTED_DASH_DOT | * @see #BORDER_SLANTED_DASH_DOT | ||||
* @deprecated 3.15 beta 2. Use {@link #setBorderBottom(BorderStyle)} instead. | * @deprecated 3.15 beta 2. Use {@link #setBorderBottom(BorderStyle)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
void setBorderBottom(short border); | void setBorderBottom(short border); | ||||
/** | /** | ||||
* set the type of border to use for the bottom border of the cell | * set the type of border to use for the bottom border of the cell | ||||
* @param border type | * @param border type | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
void setBorderBottom(BorderStyle border); | void setBorderBottom(BorderStyle border); | ||||
/** | /** | ||||
* get the type of border to use for the bottom border of the cell | * get the type of border to use for the bottom border of the cell | ||||
* @return border type | * @return border type | ||||
* @deprecated POI 3.15. Use {@link #getBorderBottomEnum()} instead. | |||||
* This will return a BorderStyle enum in the future. | |||||
*/ | |||||
short getBorderBottom(); | |||||
/** | |||||
* get the type of border to use for the bottom border of the cell | |||||
* @return border type | |||||
* @since POI 3.15 | |||||
*/ | */ | ||||
BorderStyle getBorderBottom(); | |||||
BorderStyle getBorderBottomEnum(); | |||||
/** | /** | ||||
* set the color to use for the left border | * set the color to use for the left border |
} | } | ||||
/** | /** | ||||
* @return Returns the cellType. | * @return Returns the cellType. | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
public CellType getCellType() { | |||||
public CellType getCellTypeEnum() { | |||||
return _cellType; | return _cellType; | ||||
} | } | ||||
/** | |||||
* @return Returns the cellType. | |||||
* @deprecated POI 3.15. Use {@link #getCellTypeEnum()} instead. | |||||
* In the future, the signature of this method will be changed to return a | |||||
* {@link CellType}. | |||||
*/ | |||||
@Deprecated | |||||
public int getCellType() { | |||||
return _cellType.getCode(); | |||||
} | |||||
/** | /** | ||||
* @return Returns the errorValue. | * @return Returns the errorValue. | ||||
*/ | */ |
package org.apache.poi.ss.usermodel; | package org.apache.poi.ss.usermodel; | ||||
import org.apache.poi.util.Internal; | import org.apache.poi.util.Internal; | ||||
import org.apache.poi.util.Removal; | |||||
/** | /** | ||||
* A client anchor is attached to an excel worksheet. It anchors against a | * A client anchor is attached to an excel worksheet. It anchors against a | ||||
* </p> | * </p> | ||||
* @deprecated since POI 3.14beta1 (circa 2015-11-24). Use {@link AnchorType#MOVE_AND_RESIZE} instead. | * @deprecated since POI 3.14beta1 (circa 2015-11-24). Use {@link AnchorType#MOVE_AND_RESIZE} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
public static final AnchorType MOVE_AND_RESIZE = AnchorType.MOVE_AND_RESIZE; | public static final AnchorType MOVE_AND_RESIZE = AnchorType.MOVE_AND_RESIZE; | ||||
/** | /** | ||||
* </p> | * </p> | ||||
* @deprecated since POI 3.14beta1 (circa 2015-11-24). Use {@link AnchorType#MOVE_DONT_RESIZE} instead. | * @deprecated since POI 3.14beta1 (circa 2015-11-24). Use {@link AnchorType#MOVE_DONT_RESIZE} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
public static final AnchorType MOVE_DONT_RESIZE = AnchorType.MOVE_DONT_RESIZE; | public static final AnchorType MOVE_DONT_RESIZE = AnchorType.MOVE_DONT_RESIZE; | ||||
/** | /** | ||||
* </p> | * </p> | ||||
* @deprecated since POI 3.14beta1 (circa 2015-11-24). Use {@link AnchorType#DONT_MOVE_AND_RESIZE} instead. | * @deprecated since POI 3.14beta1 (circa 2015-11-24). Use {@link AnchorType#DONT_MOVE_AND_RESIZE} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
public static final AnchorType DONT_MOVE_AND_RESIZE = AnchorType.DONT_MOVE_AND_RESIZE; | public static final AnchorType DONT_MOVE_AND_RESIZE = AnchorType.DONT_MOVE_AND_RESIZE; | ||||
/** | /** | ||||
/** | /** | ||||
* Sets the anchor type | * Sets the anchor type | ||||
* @param anchorType the anchor type to set | * @param anchorType the anchor type to set | ||||
* @since POI 3.14 | |||||
*/ | */ | ||||
public void setAnchorType( AnchorType anchorType ); | public void setAnchorType( AnchorType anchorType ); | ||||
/** | |||||
* Sets the anchor type | |||||
* @param anchorType the anchor type to set | |||||
* @deprecated POI 3.15. Use {@link #setAnchorType(AnchorType)} instead. | |||||
*/ | |||||
@Removal(version="3.17") | |||||
public void setAnchorType( int anchorType ); | |||||
/** | /** | ||||
* Gets the anchor type | * Gets the anchor type | ||||
* Changed from returning an int to an enum in POI 3.14 beta 1. | |||||
* @return the anchor type | * @return the anchor type | ||||
*/ | */ | ||||
public AnchorType getAnchorType(); | public AnchorType getAnchorType(); |
package org.apache.poi.ss.usermodel; | package org.apache.poi.ss.usermodel; | ||||
import org.apache.poi.common.usermodel.HyperlinkType; | import org.apache.poi.common.usermodel.HyperlinkType; | ||||
import org.apache.poi.util.Removal; | |||||
/** | /** | ||||
* An object that handles instantiating concrete | * An object that handles instantiating concrete | ||||
* classes of the various instances one needs for | * classes of the various instances one needs for | ||||
* HSSF and XSSF. | * HSSF and XSSF. | ||||
* Works around a major shortcoming in Java, where we | |||||
* can't have static methods on interfaces or abstract | |||||
* Works around a limitation in Java where we | |||||
* cannot have static methods on interfaces or abstract | |||||
* classes. | * classes. | ||||
* This allows you to get the appropriate class for | * This allows you to get the appropriate class for | ||||
* a given interface, without you having to worry | * a given interface, without you having to worry | ||||
* about if you're dealing with HSSF or XSSF, despite | |||||
* Java being quite rubbish. | |||||
* about if you're dealing with HSSF or XSSF. | |||||
*/ | */ | ||||
public interface CreationHelper { | public interface CreationHelper { | ||||
/** | /** | ||||
* Creates a new Hyperlink, of the given type | * Creates a new Hyperlink, of the given type | ||||
* @deprecated POI 3.15 beta 3. Use {@link #createHyperlink(HyperlinkType)} instead. | * @deprecated POI 3.15 beta 3. Use {@link #createHyperlink(HyperlinkType)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Deprecated | @Deprecated | ||||
Hyperlink createHyperlink(int type); | Hyperlink createHyperlink(int type); | ||||
VAR(10, "Var"), | VAR(10, "Var"), | ||||
VARP(11, "Varp"); | VARP(11, "Varp"); | ||||
private int value; | |||||
private String name; | |||||
private final int value; | |||||
private final String name; | |||||
DataConsolidateFunction(int value, String name) { | DataConsolidateFunction(int value, String name) { | ||||
this.value = value; | this.value = value; |
return cell.getRichStringCellValue().getString(); | return cell.getRichStringCellValue().getString(); | ||||
case BOOLEAN : | case BOOLEAN : | ||||
return String.valueOf(cell.getBooleanCellValue()); | |||||
return cell.getBooleanCellValue() ? "TRUE" : "FALSE"; | |||||
case BLANK : | case BLANK : | ||||
return ""; | return ""; | ||||
case ERROR: | case ERROR: |
return false; | return false; | ||||
} | } | ||||
public static FormulaError forInt(byte type){ | |||||
public static FormulaError forInt(byte type) throws IllegalArgumentException { | |||||
FormulaError err = bmap.get(type); | FormulaError err = bmap.get(type); | ||||
if(err == null) throw new IllegalArgumentException("Unknown error type: " + type); | if(err == null) throw new IllegalArgumentException("Unknown error type: " + type); | ||||
return err; | return err; | ||||
} | } | ||||
public static FormulaError forInt(int type){ | |||||
public static FormulaError forInt(int type) throws IllegalArgumentException { | |||||
FormulaError err = imap.get(type); | FormulaError err = imap.get(type); | ||||
if(err == null) err = bmap.get((byte)type); | if(err == null) err = bmap.get((byte)type); | ||||
if(err == null) throw new IllegalArgumentException("Unknown error type: " + type); | if(err == null) throw new IllegalArgumentException("Unknown error type: " + type); | ||||
return err; | return err; | ||||
} | } | ||||
public static FormulaError forString(String code){ | |||||
public static FormulaError forString(String code) throws IllegalArgumentException { | |||||
FormulaError err = smap.get(code); | FormulaError err = smap.get(code); | ||||
if(err == null) throw new IllegalArgumentException("Unknown error code: " + code); | if(err == null) throw new IllegalArgumentException("Unknown error code: " + code); | ||||
return err; | return err; |
* or one of {@link CellType#NUMERIC}, {@link CellType#STRING}, | * or one of {@link CellType#NUMERIC}, {@link CellType#STRING}, | ||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR} | * {@link CellType#BOOLEAN}, {@link CellType#ERROR} | ||||
* Note: the cell's type remains as CellType.FORMULA however. | * Note: the cell's type remains as CellType.FORMULA however. | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future | |||||
*/ | */ | ||||
int evaluateFormulaCell(Cell cell); | int evaluateFormulaCell(Cell cell); | ||||
import java.util.Iterator; | import java.util.Iterator; | ||||
import org.apache.poi.util.Removal; | |||||
/** | /** | ||||
* High level representation of a row of a spreadsheet. | * High level representation of a row of a spreadsheet. | ||||
*/ | */ | ||||
CREATE_NULL_AS_BLANK(3); | CREATE_NULL_AS_BLANK(3); | ||||
/** | /** | ||||
* @deprecated as of POI 3.15-beta2, scheduled for removal in 3.17 - the id has no function and will be removed | |||||
* @deprecated as of POI 3.15-beta2, scheduled for removal in 3.17 - the id has no function and will be removed. | |||||
* The {@code id} is only kept only for backwards compatibility with applications that hard-coded the number | |||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Deprecated | @Deprecated | ||||
public final int id; | public final int id; | ||||
private MissingCellPolicy(int id) { | private MissingCellPolicy(int id) { | ||||
* | * | ||||
* @deprecated as of POI 3.15-beta2, scheduled for removal in 3.17 - use the MissingCellPolicy enum | * @deprecated as of POI 3.15-beta2, scheduled for removal in 3.17 - use the MissingCellPolicy enum | ||||
**/ | **/ | ||||
@Removal(version="3.17") | |||||
@Deprecated | @Deprecated | ||||
public static final MissingCellPolicy RETURN_NULL_AND_BLANK = MissingCellPolicy.RETURN_NULL_AND_BLANK; | public static final MissingCellPolicy RETURN_NULL_AND_BLANK = MissingCellPolicy.RETURN_NULL_AND_BLANK; | ||||
/** | /** | ||||
* | * | ||||
* @deprecated as of POI 3.15-beta2, scheduled for removal in 3.17 - use the MissingCellPolicy enum | * @deprecated as of POI 3.15-beta2, scheduled for removal in 3.17 - use the MissingCellPolicy enum | ||||
**/ | **/ | ||||
@Removal(version="3.17") | |||||
@Deprecated | @Deprecated | ||||
public static final MissingCellPolicy RETURN_BLANK_AS_NULL = MissingCellPolicy.RETURN_BLANK_AS_NULL; | public static final MissingCellPolicy RETURN_BLANK_AS_NULL = MissingCellPolicy.RETURN_BLANK_AS_NULL; | ||||
/** | /** | ||||
* | * | ||||
* @deprecated as of POI 3.15-beta2, scheduled for removal in 3.17 - use the MissingCellPolicy enum | * @deprecated as of POI 3.15-beta2, scheduled for removal in 3.17 - use the MissingCellPolicy enum | ||||
**/ | **/ | ||||
@Removal(version="3.17") | |||||
@Deprecated | @Deprecated | ||||
public static final MissingCellPolicy CREATE_NULL_AS_BLANK = MissingCellPolicy.CREATE_NULL_AS_BLANK; | public static final MissingCellPolicy CREATE_NULL_AS_BLANK = MissingCellPolicy.CREATE_NULL_AS_BLANK; | ||||
return new AbstractCellRangeDataSource<Number>(sheet, cellRangeAddress) { | return new AbstractCellRangeDataSource<Number>(sheet, cellRangeAddress) { | ||||
public Number getPointAt(int index) { | public Number getPointAt(int index) { | ||||
CellValue cellValue = getCellValueAt(index); | CellValue cellValue = getCellValueAt(index); | ||||
if (cellValue != null && cellValue.getCellType() == CellType.NUMERIC) { | |||||
if (cellValue != null && cellValue.getCellTypeEnum() == CellType.NUMERIC) { | |||||
return Double.valueOf(cellValue.getNumberValue()); | return Double.valueOf(cellValue.getNumberValue()); | ||||
} else { | } else { | ||||
return null; | return null; | ||||
return new AbstractCellRangeDataSource<String>(sheet, cellRangeAddress) { | return new AbstractCellRangeDataSource<String>(sheet, cellRangeAddress) { | ||||
public String getPointAt(int index) { | public String getPointAt(int index) { | ||||
CellValue cellValue = getCellValueAt(index); | CellValue cellValue = getCellValueAt(index); | ||||
if (cellValue != null && cellValue.getCellType() == CellType.STRING) { | |||||
if (cellValue != null && cellValue.getCellTypeEnum() == CellType.STRING) { | |||||
return cellValue.getStringValue(); | return cellValue.getStringValue(); | ||||
} else { | } else { | ||||
return null; | return null; |
Map<String, Object> properties = new HashMap<String, Object>(); | Map<String, Object> properties = new HashMap<String, Object>(); | ||||
put(properties, ALIGNMENT, style.getAlignmentEnum()); | put(properties, ALIGNMENT, style.getAlignmentEnum()); | ||||
put(properties, VERTICAL_ALIGNMENT, style.getVerticalAlignmentEnum()); | put(properties, VERTICAL_ALIGNMENT, style.getVerticalAlignmentEnum()); | ||||
put(properties, BORDER_BOTTOM, style.getBorderBottom()); | |||||
put(properties, BORDER_LEFT, style.getBorderLeft()); | |||||
put(properties, BORDER_RIGHT, style.getBorderRight()); | |||||
put(properties, BORDER_TOP, style.getBorderTop()); | |||||
put(properties, BORDER_BOTTOM, style.getBorderBottomEnum()); | |||||
put(properties, BORDER_LEFT, style.getBorderLeftEnum()); | |||||
put(properties, BORDER_RIGHT, style.getBorderRightEnum()); | |||||
put(properties, BORDER_TOP, style.getBorderTopEnum()); | |||||
put(properties, BOTTOM_BORDER_COLOR, style.getBottomBorderColor()); | put(properties, BOTTOM_BORDER_COLOR, style.getBottomBorderColor()); | ||||
put(properties, DATA_FORMAT, style.getDataFormat()); | put(properties, DATA_FORMAT, style.getDataFormat()); | ||||
put(properties, FILL_PATTERN, style.getFillPatternEnum()); | put(properties, FILL_PATTERN, style.getFillPatternEnum()); |
/** | /** | ||||
* This holds the common functionality for all POI OOXML Document classes. | * This holds the common functionality for all POI OOXML Document classes. | ||||
*/ | */ | ||||
// TODO: implements AutoCloseable in Java 7+ when POI drops support for Java 6. | |||||
public abstract class POIXMLDocument extends POIXMLDocumentPart implements Closeable { | public abstract class POIXMLDocument extends POIXMLDocumentPart implements Closeable { | ||||
public static final String DOCUMENT_CREATOR = "Apache POI"; | public static final String DOCUMENT_CREATOR = "Apache POI"; | ||||
*/ | */ | ||||
@SuppressWarnings("resource") | @SuppressWarnings("resource") | ||||
public final void write(OutputStream stream) throws IOException { | public final void write(OutputStream stream) throws IOException { | ||||
OPCPackage p = getPackage(); | |||||
if(p == null) { | |||||
throw new IOException("Cannot write data, document seems to have been closed already"); | |||||
} | |||||
//force all children to commit their changes into the underlying OOXML Package | //force all children to commit their changes into the underlying OOXML Package | ||||
// TODO Shouldn't they be committing to the new one instead? | // TODO Shouldn't they be committing to the new one instead? | ||||
Set<PackagePart> context = new HashSet<PackagePart>(); | Set<PackagePart> context = new HashSet<PackagePart>(); | ||||
//save extended and custom properties | //save extended and custom properties | ||||
getProperties().commit(); | getProperties().commit(); | ||||
OPCPackage p = getPackage(); | |||||
if(p == null) { | |||||
throw new IOException("Cannot write data, document seems to have been closed already"); | |||||
} | |||||
p.save(stream); | p.save(stream); | ||||
} | } | ||||
} | } |
* @throws InvalidFormatException | * @throws InvalidFormatException | ||||
* If the specified file doesn't exist, and a parsing error | * If the specified file doesn't exist, and a parsing error | ||||
* occur. | * occur. | ||||
* @throws InvalidOperationException | |||||
*/ | */ | ||||
public static OPCPackage open(String path, PackageAccess access) | public static OPCPackage open(String path, PackageAccess access) | ||||
throws InvalidFormatException { | |||||
throws InvalidFormatException, InvalidOperationException { | |||||
if (path == null || "".equals(path.trim())) { | if (path == null || "".equals(path.trim())) { | ||||
throw new IllegalArgumentException("'path' must be given"); | throw new IllegalArgumentException("'path' must be given"); | ||||
} | } | ||||
} | } | ||||
OPCPackage pack = new ZipPackage(path, access); | OPCPackage pack = new ZipPackage(path, access); | ||||
boolean success = false; | |||||
if (pack.partList == null && access != PackageAccess.WRITE) { | if (pack.partList == null && access != PackageAccess.WRITE) { | ||||
pack.getParts(); | |||||
try { | |||||
pack.getParts(); | |||||
success = true; | |||||
} finally { | |||||
if (! success) { | |||||
try { | |||||
pack.close(); | |||||
} catch (final IOException e) { | |||||
throw new InvalidOperationException("Could not close OPCPackage while cleaning up", e); | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
pack.originalPackagePath = new File(path).getAbsolutePath(); | pack.originalPackagePath = new File(path).getAbsolutePath(); | ||||
return pack; | return pack; |
import java.io.File; | import java.io.File; | ||||
import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
import java.io.FileNotFoundException; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.OutputStream; | import java.io.OutputStream; | ||||
* Physical zip package. | * Physical zip package. | ||||
*/ | */ | ||||
public final class ZipPackage extends OPCPackage { | public final class ZipPackage extends OPCPackage { | ||||
private static POILogger logger = POILogFactory.getLogger(ZipPackage.class); | |||||
private static final String MIMETYPE = "mimetype"; | |||||
private static final String SETTINGS_XML = "settings.xml"; | |||||
private static final POILogger logger = POILogFactory.getLogger(ZipPackage.class); | |||||
/** | /** | ||||
* Zip archive, as either a file on disk, | * Zip archive, as either a file on disk, | ||||
* @throws IllegalArgumentException | * @throws IllegalArgumentException | ||||
* If the specified input stream not an instance of | * If the specified input stream not an instance of | ||||
* ZipInputStream. | * ZipInputStream. | ||||
* @throws IOException | |||||
* if input stream cannot be opened, read, or closed | |||||
*/ | */ | ||||
ZipPackage(InputStream in, PackageAccess access) throws IOException { | ZipPackage(InputStream in, PackageAccess access) throws IOException { | ||||
super(access); | super(access); | ||||
@SuppressWarnings("resource") | |||||
ThresholdInputStream zis = ZipHelper.openZipStream(in); | ThresholdInputStream zis = ZipHelper.openZipStream(in); | ||||
this.zipArchive = new ZipInputStreamZipEntrySource(zis); | |||||
try { | |||||
this.zipArchive = new ZipInputStreamZipEntrySource(zis); | |||||
} catch (final IOException e) { | |||||
try { | |||||
zis.close(); | |||||
} catch (final IOException e2) { | |||||
throw new IOException("Failed to close zip input stream while cleaning up. " + e.getMessage(), e2); | |||||
} | |||||
throw new IOException("Failed to read zip entry source", e); | |||||
} | |||||
} | } | ||||
/** | /** | ||||
* The path of the file to open or create. | * The path of the file to open or create. | ||||
* @param access | * @param access | ||||
* The package access mode. | * The package access mode. | ||||
* @throws InvalidOperationException | |||||
*/ | */ | ||||
ZipPackage(String path, PackageAccess access) { | |||||
ZipPackage(String path, PackageAccess access) throws InvalidOperationException { | |||||
this(new File(path), access); | this(new File(path), access); | ||||
} | } | ||||
* The file to open or create. | * The file to open or create. | ||||
* @param access | * @param access | ||||
* The package access mode. | * The package access mode. | ||||
* @throws InvalidOperationException | |||||
*/ | */ | ||||
@SuppressWarnings("resource") | |||||
ZipPackage(File file, PackageAccess access) { | |||||
ZipPackage(File file, PackageAccess access) throws InvalidOperationException { | |||||
super(access); | super(access); | ||||
ZipEntrySource ze; | ZipEntrySource ze; | ||||
throw new InvalidOperationException("Can't open the specified file: '" + file + "'", e); | throw new InvalidOperationException("Can't open the specified file: '" + file + "'", e); | ||||
} | } | ||||
logger.log(POILogger.ERROR, "Error in zip file "+file+" - falling back to stream processing (i.e. ignoring zip central directory)"); | logger.log(POILogger.ERROR, "Error in zip file "+file+" - falling back to stream processing (i.e. ignoring zip central directory)"); | ||||
// some zips can't be opened via ZipFile in JDK6, as the central directory | |||||
// contains either non-latin entries or the compression type can't be handled | |||||
// the workaround is to iterate over the stream and not the directory | |||||
FileInputStream fis = null; | |||||
ThresholdInputStream zis = null; | |||||
ze = openZipEntrySourceStream(file); | |||||
} | |||||
this.zipArchive = ze; | |||||
} | |||||
private static ZipEntrySource openZipEntrySourceStream(File file) throws InvalidOperationException { | |||||
final FileInputStream fis; | |||||
// Acquire a resource that is needed to read the next level of openZipEntrySourceStream | |||||
try { | |||||
// open the file input stream | |||||
fis = new FileInputStream(file); | |||||
} catch (final FileNotFoundException e) { | |||||
// If the source cannot be acquired, abort (no resources to free at this level) | |||||
throw new InvalidOperationException("Can't open the specified file input stream from file: '" + file + "'", e); | |||||
} | |||||
// If an error occurs while reading the next level of openZipEntrySourceStream, free the acquired resource | |||||
try { | |||||
// read from the file input stream | |||||
return openZipEntrySourceStream(fis); | |||||
} catch (final Exception e) { | |||||
try { | try { | ||||
fis = new FileInputStream(file); | |||||
zis = ZipHelper.openZipStream(fis); | |||||
ze = new ZipInputStreamZipEntrySource(zis); | |||||
} catch (IOException e2) { | |||||
if (zis != null) { | |||||
try { | |||||
zis.close(); | |||||
} catch (IOException e3) { | |||||
throw new InvalidOperationException("Can't open the specified file: '" + file + "'"+ | |||||
" and couldn't close the file input stream", e); | |||||
} | |||||
} else if (fis != null) { | |||||
try { | |||||
fis.close(); | |||||
} catch (IOException e3) { | |||||
throw new InvalidOperationException("Can't open the specified file: '" + file + "'"+ | |||||
" and couldn't close the file input stream", e); | |||||
} | |||||
} | |||||
throw new InvalidOperationException("Can't open the specified file: '" + file + "'", e); | |||||
// abort: close the file input stream | |||||
fis.close(); | |||||
} catch (final IOException e2) { | |||||
throw new InvalidOperationException("Could not close the specified file input stream from file: '" + file + "'", e2); | |||||
} | } | ||||
throw new InvalidOperationException("Failed to read the file input stream from file: '" + file + "'", e); | |||||
} | |||||
} | |||||
private static ZipEntrySource openZipEntrySourceStream(FileInputStream fis) throws InvalidOperationException { | |||||
final ThresholdInputStream zis; | |||||
// Acquire a resource that is needed to read the next level of openZipEntrySourceStream | |||||
try { | |||||
// open the zip input stream | |||||
zis = ZipHelper.openZipStream(fis); | |||||
} catch (final IOException e) { | |||||
// If the source cannot be acquired, abort (no resources to free at this level) | |||||
throw new InvalidOperationException("Could not open the file input stream", e); | |||||
} | |||||
// If an error occurs while reading the next level of openZipEntrySourceStream, free the acquired resource | |||||
try { | |||||
// read from the zip input stream | |||||
return openZipEntrySourceStream(zis); | |||||
} catch (final Exception e) { | |||||
try { | |||||
// abort: close the zip input stream | |||||
zis.close(); | |||||
} catch (final IOException e2) { | |||||
throw new InvalidOperationException("Failed to read the zip entry source stream and could not close the zip input stream", e2); | |||||
} | |||||
throw new InvalidOperationException("Failed to read the zip entry source stream", e); | |||||
} | |||||
} | |||||
private static ZipEntrySource openZipEntrySourceStream(ThresholdInputStream zis) throws InvalidOperationException { | |||||
// Acquire the final level resource. If this is acquired successfully, the zip package was read successfully from the input stream | |||||
try { | |||||
// open the zip entry source stream | |||||
return new ZipInputStreamZipEntrySource(zis); | |||||
} catch (IOException e) { | |||||
throw new InvalidOperationException("Could not open the specified zip entry source stream", e); | |||||
} | } | ||||
this.zipArchive = ze; | |||||
} | } | ||||
/** | /** | ||||
this.contentTypeManager = new ZipContentTypeManager( | this.contentTypeManager = new ZipContentTypeManager( | ||||
getZipArchive().getInputStream(entry), this); | getZipArchive().getInputStream(entry), this); | ||||
} catch (IOException e) { | } catch (IOException e) { | ||||
throw new InvalidFormatException(e.getMessage()); | |||||
throw new InvalidFormatException(e.getMessage(), e); | |||||
} | } | ||||
break; | break; | ||||
} | } | ||||
boolean hasSettingsXML = false; | boolean hasSettingsXML = false; | ||||
entries = this.zipArchive.getEntries(); | entries = this.zipArchive.getEntries(); | ||||
while (entries.hasMoreElements()) { | while (entries.hasMoreElements()) { | ||||
ZipEntry entry = entries.nextElement(); | |||||
if (entry.getName().equals("mimetype")) { | |||||
final ZipEntry entry = entries.nextElement(); | |||||
final String name = entry.getName(); | |||||
if (MIMETYPE.equals(name)) { | |||||
hasMimetype = true; | hasMimetype = true; | ||||
} | } | ||||
if (entry.getName().equals("settings.xml")) { | |||||
if (SETTINGS_XML.equals(name)) { | |||||
hasSettingsXML = true; | hasSettingsXML = true; | ||||
} | } | ||||
numEntries++; | numEntries++; | ||||
String contentType = contentTypeManager.getContentType(partName); | String contentType = contentTypeManager.getContentType(partName); | ||||
if (contentType != null && contentType.equals(ContentTypes.RELATIONSHIPS_PART)) { | if (contentType != null && contentType.equals(ContentTypes.RELATIONSHIPS_PART)) { | ||||
try { | try { | ||||
partList.put(partName, new ZipPackagePart(this, entry, | |||||
partName, contentType)); | |||||
PackagePart part = new ZipPackagePart(this, entry, partName, contentType); | |||||
partList.put(partName, part); | |||||
} catch (InvalidOperationException e) { | } catch (InvalidOperationException e) { | ||||
throw new InvalidFormatException(e.getMessage()); | |||||
throw new InvalidFormatException(e.getMessage(), e); | |||||
} | } | ||||
} | } | ||||
} | } | ||||
PackagePartName partName = buildPartName(entry); | PackagePartName partName = buildPartName(entry); | ||||
if(partName == null) continue; | if(partName == null) continue; | ||||
String contentType = contentTypeManager | |||||
.getContentType(partName); | |||||
String contentType = contentTypeManager.getContentType(partName); | |||||
if (contentType != null && contentType.equals(ContentTypes.RELATIONSHIPS_PART)) { | if (contentType != null && contentType.equals(ContentTypes.RELATIONSHIPS_PART)) { | ||||
// Already handled | // Already handled | ||||
} | } | ||||
else if (contentType != null) { | else if (contentType != null) { | ||||
try { | try { | ||||
partList.put(partName, new ZipPackagePart(this, entry, | |||||
partName, contentType)); | |||||
PackagePart part = new ZipPackagePart(this, entry, partName, contentType); | |||||
partList.put(partName, part); | |||||
} catch (InvalidOperationException e) { | } catch (InvalidOperationException e) { | ||||
throw new InvalidFormatException(e.getMessage()); | |||||
throw new InvalidFormatException(e.getMessage(), e); | |||||
} | } | ||||
} else { | } else { | ||||
throw new InvalidFormatException( | throw new InvalidFormatException( | ||||
// Save the final package to a temporary file | // Save the final package to a temporary file | ||||
try { | try { | ||||
save(tempFile); | save(tempFile); | ||||
// Close the current zip file, so we can | |||||
// overwrite it on all platforms | |||||
this.zipArchive.close(); | |||||
// Copy the new file over the old one | |||||
FileHelper.copyFile(tempFile, targetFile); | |||||
} finally { | } finally { | ||||
// Either the save operation succeed or not, we delete the | |||||
// temporary file | |||||
if (!tempFile.delete()) { | |||||
logger | |||||
.log(POILogger.WARN,"The temporary file: '" | |||||
+ targetFile.getAbsolutePath() | |||||
+ "' cannot be deleted ! Make sure that no other application use it."); | |||||
try { | |||||
// Close the current zip file, so we can | |||||
// overwrite it on all platforms | |||||
this.zipArchive.close(); | |||||
// Copy the new file over the old one | |||||
FileHelper.copyFile(tempFile, targetFile); | |||||
} finally { | |||||
// Either the save operation succeed or not, we delete the | |||||
// temporary file | |||||
if (!tempFile.delete()) { | |||||
logger | |||||
.log(POILogger.WARN,"The temporary file: '" | |||||
+ targetFile.getAbsolutePath() | |||||
+ "' cannot be deleted ! Make sure that no other application use it."); | |||||
} | |||||
} | } | ||||
} | } | ||||
} else { | } else { |
import java.io.File; | import java.io.File; | ||||
import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
import java.io.FileNotFoundException; | |||||
import java.io.IOException; | import java.io.IOException; | ||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.PushbackInputStream; | import java.io.PushbackInputStream; | ||||
* @param file | * @param file | ||||
* The file to open. | * The file to open. | ||||
* @return The zip archive freshly open. | * @return The zip archive freshly open. | ||||
* @throws IOException if the zip file cannot be opened or closed to read the header signature | |||||
* @throws NotOfficeXmlFileException if stream does not start with zip header signature | |||||
*/ | */ | ||||
public static ZipFile openZipFile(File file) throws IOException { | |||||
public static ZipFile openZipFile(File file) throws IOException, NotOfficeXmlFileException { | |||||
if (!file.exists()) { | if (!file.exists()) { | ||||
return null; | |||||
throw new FileNotFoundException("File does not exist"); | |||||
} | |||||
if (file.isDirectory()) { | |||||
throw new IOException("File is a directory"); | |||||
} | } | ||||
// Peek at the first few bytes to sanity check | // Peek at the first few bytes to sanity check |
* resources may be freed | * resources may be freed | ||||
*/ | */ | ||||
public void close() throws IOException; | public void close() throws IOException; | ||||
/** | |||||
* Has close been called already? | |||||
*/ | |||||
public boolean isClosed(); | |||||
} | } |
} | } | ||||
zipArchive = null; | zipArchive = null; | ||||
} | } | ||||
public boolean isClosed() { | |||||
return (zipArchive == null); | |||||
} | |||||
public Enumeration<? extends ZipEntry> getEntries() { | public Enumeration<? extends ZipEntry> getEntries() { | ||||
if (zipArchive == null) | if (zipArchive == null) |
// Free the memory | // Free the memory | ||||
zipEntries = null; | zipEntries = null; | ||||
} | } | ||||
public boolean isClosed() { | |||||
return (zipEntries == null); | |||||
} | |||||
/** | /** | ||||
* Why oh why oh why are Iterator and Enumeration | * Why oh why oh why are Iterator and Enumeration |
return MAX_TEXT_SIZE; | return MAX_TEXT_SIZE; | ||||
} | } | ||||
public ZipSecureFile(File file, int mode) throws IOException { | |||||
public ZipSecureFile(File file, int mode) throws ZipException, IOException { | |||||
super(file, mode); | super(file, mode); | ||||
} | } | ||||
public ZipSecureFile(File file) throws IOException { | |||||
public ZipSecureFile(File file) throws ZipException, IOException { | |||||
super(file); | super(file); | ||||
} | } | ||||
public ZipSecureFile(String name) throws IOException { | |||||
public ZipSecureFile(String name) throws ZipException, IOException { | |||||
super(name); | super(name); | ||||
} | } | ||||
* @param format The format of the picture | * @param format The format of the picture | ||||
* | * | ||||
* @return the picture data | * @return the picture data | ||||
* @since 3.15 beta 2 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public XSLFPictureData addPicture(InputStream is, PictureType format) throws IOException | public XSLFPictureData addPicture(InputStream is, PictureType format) throws IOException | ||||
* @param format The format of the picture. | * @param format The format of the picture. | ||||
* | * | ||||
* @return the picture data | * @return the picture data | ||||
* @since 3.15 beta 2 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public XSLFPictureData addPicture(File pict, PictureType format) throws IOException | public XSLFPictureData addPicture(File pict, PictureType format) throws IOException | ||||
* | * | ||||
* @param pictureData The picture data to find in the SlideShow | * @param pictureData The picture data to find in the SlideShow | ||||
* @return {@code null} if picture data is not found in this slideshow | * @return {@code null} if picture data is not found in this slideshow | ||||
* @since 3.15 beta 2 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public XSLFPictureData findPictureData(byte[] pictureData) { | public XSLFPictureData findPictureData(byte[] pictureData) { |
_link.setTooltip(label); | _link.setTooltip(label); | ||||
} | } | ||||
/* (non-Javadoc) | |||||
* @deprecated POI 3.15. Use {@link #getTypeEnum()} instead. | |||||
* Will return a HyperlinkType enum in the future | |||||
*/ | |||||
@Override | @Override | ||||
public int getType() { | public int getType() { | ||||
return getTypeEnum().getCode(); | return getTypeEnum().getCode(); |
* Represents a table in a .pptx presentation | * Represents a table in a .pptx presentation | ||||
*/ | */ | ||||
public class XSLFTableRow implements Iterable<XSLFTableCell> { | public class XSLFTableRow implements Iterable<XSLFTableCell> { | ||||
private CTTableRow _row; | |||||
private List<XSLFTableCell> _cells; | |||||
private XSLFTable _table; | |||||
private final CTTableRow _row; | |||||
private final List<XSLFTableCell> _cells; | |||||
private final XSLFTable _table; | |||||
/*package*/ XSLFTableRow(CTTableRow row, XSLFTable table){ | /*package*/ XSLFTableRow(CTTableRow row, XSLFTable table){ | ||||
_row = row; | _row = row; | ||||
_table.updateRowColIndexes(); | _table.updateRowColIndexes(); | ||||
return cell; | return cell; | ||||
} | } | ||||
/** | |||||
* Merge cells of a table row, inclusive. | |||||
* Indices are 0-based. | |||||
* | |||||
* @param firstCol 0-based index of first column to merge, inclusive | |||||
* @param lastCol 0-based index of last column to merge, inclusive | |||||
*/ | |||||
public void mergeCells(int firstCol, int lastCol) | |||||
{ | |||||
if (firstCol >= lastCol) { | |||||
throw new IllegalArgumentException( | |||||
"Cannot merge, first column >= last column : " | |||||
+ firstCol + " >= " + lastCol | |||||
); | |||||
} | |||||
final int colSpan = (lastCol - firstCol) + 1; | |||||
_cells.get(firstCol).setGridSpan(colSpan); | |||||
for (final XSLFTableCell cell : _cells.subList(firstCol+1, lastCol+1)) { | |||||
cell.setHMerge(true); | |||||
} | |||||
} | |||||
} | } |
import org.apache.poi.util.NotImplemented; | import org.apache.poi.util.NotImplemented; | ||||
import org.apache.poi.util.POILogFactory; | import org.apache.poi.util.POILogFactory; | ||||
import org.apache.poi.util.POILogger; | import org.apache.poi.util.POILogger; | ||||
import org.apache.poi.util.Removal; | |||||
import org.apache.poi.xssf.usermodel.XSSFHyperlink; | import org.apache.poi.xssf.usermodel.XSSFHyperlink; | ||||
import org.apache.poi.xssf.usermodel.XSSFRichTextString; | import org.apache.poi.xssf.usermodel.XSSFRichTextString; | ||||
* @deprecated 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 be deleted when we make the CellType enum transition. See bug 59791. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Deprecated | |||||
public SXSSFCell(SXSSFRow row, int cellType) | public SXSSFCell(SXSSFRow row, int cellType) | ||||
{ | { | ||||
this(row, CellType.forInt((cellType))); | this(row, CellType.forInt((cellType))); |
import org.apache.poi.util.Internal; | import org.apache.poi.util.Internal; | ||||
import org.apache.poi.util.POILogFactory; | import org.apache.poi.util.POILogFactory; | ||||
import org.apache.poi.util.POILogger; | import org.apache.poi.util.POILogger; | ||||
import org.apache.poi.util.Removal; | |||||
import org.apache.poi.xssf.usermodel.XSSFCreationHelper; | import org.apache.poi.xssf.usermodel.XSSFCreationHelper; | ||||
import org.apache.poi.xssf.usermodel.XSSFRichTextString; | import org.apache.poi.xssf.usermodel.XSSFRichTextString; | ||||
* @deprecated POI 3.15 beta 3. Use {@link #createHyperlink(HyperlinkType)} instead. | * @deprecated POI 3.15 beta 3. Use {@link #createHyperlink(HyperlinkType)} instead. | ||||
*/ | */ | ||||
@Deprecated | @Deprecated | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public Hyperlink createHyperlink(int type) { | public Hyperlink createHyperlink(int type) { | ||||
return helper.createHyperlink(type); | return helper.createHyperlink(type); |
return new SXSSFEvaluationCell((SXSSFCell)cell); | return new SXSSFEvaluationCell((SXSSFCell)cell); | ||||
} | } | ||||
/** | |||||
* If cell contains formula, it evaluates the formula, and | |||||
* puts the formula result back into the cell, in place | |||||
* of the old formula. | |||||
* Else if cell does not contain formula, this method leaves | |||||
* the cell unchanged. | |||||
* Note that the same instance of SXSSFCell is returned to | |||||
* allow chained calls like: | |||||
* <pre> | |||||
* int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType(); | |||||
* </pre> | |||||
* Be aware that your cell value will be changed to hold the | |||||
* result of the formula. If you simply want the formula | |||||
* value computed for you, use {@link #evaluateFormulaCellEnum(org.apache.poi.ss.usermodel.Cell)} } | |||||
*/ | |||||
@Override | |||||
public SXSSFCell evaluateInCell(Cell cell) { | public SXSSFCell evaluateInCell(Cell cell) { | ||||
doEvaluateInCell(cell); | |||||
return (SXSSFCell)cell; | |||||
return (SXSSFCell) super.evaluateInCell(cell); | |||||
} | } | ||||
/** | /** |
import org.apache.poi.ss.usermodel.Cell; | import org.apache.poi.ss.usermodel.Cell; | ||||
import org.apache.poi.ss.usermodel.CellType; | import org.apache.poi.ss.usermodel.CellType; | ||||
import org.apache.poi.ss.usermodel.CellValue; | import org.apache.poi.ss.usermodel.CellValue; | ||||
import org.apache.poi.util.Internal; | |||||
import org.apache.poi.ss.usermodel.RichTextString; | |||||
/** | /** | ||||
* Internal POI use only - parent of XSSF and SXSSF formula evaluators | * Internal POI use only - parent of XSSF and SXSSF formula evaluators | ||||
protected BaseXSSFFormulaEvaluator(WorkbookEvaluator bookEvaluator) { | protected BaseXSSFFormulaEvaluator(WorkbookEvaluator bookEvaluator) { | ||||
super(bookEvaluator); | super(bookEvaluator); | ||||
} | } | ||||
@Override | |||||
protected RichTextString createRichTextString(String str) { | |||||
return new XSSFRichTextString(str); | |||||
} | |||||
public void notifySetFormula(Cell cell) { | public void notifySetFormula(Cell cell) { | ||||
_bookEvaluator.notifyUpdateCell(new XSSFEvaluationCell((XSSFCell)cell)); | _bookEvaluator.notifyUpdateCell(new XSSFEvaluationCell((XSSFCell)cell)); | ||||
_bookEvaluator.notifyUpdateCell(new XSSFEvaluationCell((XSSFCell)cell)); | _bookEvaluator.notifyUpdateCell(new XSSFEvaluationCell((XSSFCell)cell)); | ||||
} | } | ||||
/** | |||||
* If cell contains formula, it evaluates the formula, | |||||
* and saves the result of the formula. The cell | |||||
* remains as a formula cell. | |||||
* Else if cell does not contain formula, this method leaves | |||||
* the cell unchanged. | |||||
* Note that the type of the formula result is returned, | |||||
* so you know what kind of value is also stored with | |||||
* the formula. | |||||
* <pre> | |||||
* CellType evaluatedCellType = evaluator.evaluateFormulaCellEnum(cell); | |||||
* </pre> | |||||
* Be aware that your cell will hold both the formula, | |||||
* and the result. If you want the cell replaced with | |||||
* the result of the formula, use {@link #evaluate(org.apache.poi.ss.usermodel.Cell)} } | |||||
* @param cell The cell to evaluate | |||||
* @return The type of the formula result (the cell's type remains as CellType.FORMULA however) | |||||
* If cell is not a formula cell, returns {@link CellType#_NONE} rather than throwing an exception. | |||||
* @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. | |||||
*/ | |||||
@Internal(since="POI 3.15 beta 3") | |||||
public CellType evaluateFormulaCellEnum(Cell cell) { | |||||
if (cell == null || cell.getCellTypeEnum() != CellType.FORMULA) { | |||||
return CellType._NONE; | |||||
} | |||||
CellValue cv = evaluateFormulaCellValue(cell); | |||||
// cell remains a formula cell, but the cached value is changed | |||||
setCellValue(cell, cv); | |||||
return cv.getCellType(); | |||||
} | |||||
/** | |||||
* If cell contains formula, it evaluates the formula, and | |||||
* puts the formula result back into the cell, in place | |||||
* of the old formula. | |||||
* Else if cell does not contain formula, this method leaves | |||||
* the cell unchanged. | |||||
*/ | |||||
protected void doEvaluateInCell(Cell cell) { | |||||
if (cell == null) return; | |||||
if (cell.getCellTypeEnum() == CellType.FORMULA) { | |||||
CellValue cv = evaluateFormulaCellValue(cell); | |||||
setCellType(cell, cv); // cell will no longer be a formula cell | |||||
setCellValue(cell, cv); | |||||
} | |||||
} | |||||
private static void setCellValue(Cell cell, CellValue cv) { | |||||
CellType cellType = cv.getCellType(); | |||||
switch (cellType) { | |||||
case BOOLEAN: | |||||
cell.setCellValue(cv.getBooleanValue()); | |||||
break; | |||||
case ERROR: | |||||
cell.setCellErrorValue(cv.getErrorValue()); | |||||
break; | |||||
case NUMERIC: | |||||
cell.setCellValue(cv.getNumberValue()); | |||||
break; | |||||
case STRING: | |||||
cell.setCellValue(new XSSFRichTextString(cv.getStringValue())); | |||||
break; | |||||
case BLANK: | |||||
// never happens - blanks eventually get translated to zero | |||||
case FORMULA: | |||||
// this will never happen, we have already evaluated the formula | |||||
default: | |||||
throw new IllegalStateException("Unexpected cell value type (" + cellType + ")"); | |||||
} | |||||
} | |||||
/** | /** | ||||
* Turns a XSSFCell / SXSSFCell into a XSSFEvaluationCell | * Turns a XSSFCell / SXSSFCell into a XSSFEvaluationCell | ||||
*/ | */ |
_border = border; | _border = border; | ||||
} | } | ||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderBottomEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
@Override | |||||
public short getBorderBottom() { | |||||
return getBorderBottomEnum().getCode(); | |||||
} | |||||
/** | |||||
* @since POI 3.15 | |||||
*/ | |||||
@Override | @Override | ||||
public BorderStyle getBorderBottom() { | |||||
public BorderStyle getBorderBottomEnum() { | |||||
STBorderStyle.Enum ptrn = _border.isSetBottom() ? _border.getBottom().getStyle() : null; | STBorderStyle.Enum ptrn = _border.isSetBottom() ? _border.getBottom().getStyle() : null; | ||||
return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | ||||
} | } | ||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderDiagonalEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
@Override | @Override | ||||
public BorderStyle getBorderDiagonal() { | |||||
public short getBorderDiagonal() { | |||||
return getBorderDiagonalEnum().getCode(); | |||||
} | |||||
/** | |||||
* @since POI 3.15 | |||||
*/ | |||||
@Override | |||||
public BorderStyle getBorderDiagonalEnum() { | |||||
STBorderStyle.Enum ptrn = _border.isSetDiagonal() ? _border.getDiagonal().getStyle() : null; | STBorderStyle.Enum ptrn = _border.isSetDiagonal() ? _border.getDiagonal().getStyle() : null; | ||||
return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | ||||
} | } | ||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderLeftEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
@Override | |||||
public short getBorderLeft() { | |||||
return getBorderLeftEnum().getCode(); | |||||
} | |||||
/** | |||||
* @since POI 3.15 | |||||
*/ | |||||
@Override | @Override | ||||
public BorderStyle getBorderLeft() { | |||||
public BorderStyle getBorderLeftEnum() { | |||||
STBorderStyle.Enum ptrn = _border.isSetLeft() ? _border.getLeft().getStyle() : null; | STBorderStyle.Enum ptrn = _border.isSetLeft() ? _border.getLeft().getStyle() : null; | ||||
return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | ||||
} | } | ||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderRightEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
@Override | @Override | ||||
public BorderStyle getBorderRight() { | |||||
public short getBorderRight() { | |||||
return getBorderRightEnum().getCode(); | |||||
} | |||||
/** | |||||
* @since POI 3.15 | |||||
*/ | |||||
@Override | |||||
public BorderStyle getBorderRightEnum() { | |||||
STBorderStyle.Enum ptrn = _border.isSetRight() ? _border.getRight().getStyle() : null; | STBorderStyle.Enum ptrn = _border.isSetRight() ? _border.getRight().getStyle() : null; | ||||
return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | ||||
} | } | ||||
/** | |||||
* @deprecated POI 3.15. Use {@link #getBorderTopEnum()}. | |||||
* This method will return an BorderStyle enum in the future. | |||||
*/ | |||||
@Override | |||||
public short getBorderTop() { | |||||
return getBorderTopEnum().getCode(); | |||||
} | |||||
/** | |||||
* @since POI 3.15 | |||||
*/ | |||||
@Override | @Override | ||||
public BorderStyle getBorderTop() { | |||||
public BorderStyle getBorderTopEnum() { | |||||
STBorderStyle.Enum ptrn = _border.isSetTop() ? _border.getTop().getStyle() : null; | STBorderStyle.Enum ptrn = _border.isSetTop() ? _border.getTop().getStyle() : null; | ||||
return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | return ptrn == null ? BorderStyle.NONE : BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | ||||
} | } |
* For forwards compatibility, do not hard-code cell type literals in your code. | * For forwards compatibility, do not hard-code cell type literals in your code. | ||||
* | * | ||||
* @return the cell type | * @return the cell type | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public int getCellType() { | public int getCellType() { | ||||
* @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, | * @return one of ({@link CellType#NUMERIC}, {@link CellType#STRING}, | ||||
* {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending | * {@link CellType#BOOLEAN}, {@link CellType#ERROR}) depending | ||||
* on the cached value of the formula | * on the cached value of the formula | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public int getCachedFormulaResultType() { | public int getCachedFormulaResultType() { | ||||
* @deprecated 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 be deleted when we make the CellType enum transition. See bug 59791. | ||||
*/ | */ | ||||
@Internal(since="POI 3.15 beta 3") | |||||
@Override | @Override | ||||
public CellType getCachedFormulaResultTypeEnum() { | public CellType getCachedFormulaResultTypeEnum() { | ||||
if (! isFormulaCell()) { | if (! isFormulaCell()) { | ||||
* @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType#ERROR} | * @throws IllegalStateException if the cell type returned by {@link #getCellTypeEnum()} isn't {@link CellType#ERROR} | ||||
* @see FormulaError | * @see FormulaError | ||||
*/ | */ | ||||
public String getErrorCellString() { | |||||
public String getErrorCellString() throws IllegalStateException { | |||||
CellType cellType = getBaseCellType(true); | CellType cellType = getBaseCellType(true); | ||||
if(cellType != CellType.ERROR) throw typeMismatch(CellType.ERROR, cellType, false); | if(cellType != CellType.ERROR) throw typeMismatch(CellType.ERROR, cellType, false); | ||||
* @see FormulaError | * @see FormulaError | ||||
*/ | */ | ||||
@Override | @Override | ||||
public byte getErrorCellValue() { | |||||
public byte getErrorCellValue() throws IllegalStateException { | |||||
String code = getErrorCellString(); | String code = getErrorCellString(); | ||||
if (code == null) { | if (code == null) { | ||||
return 0; | return 0; | ||||
} | } | ||||
return FormulaError.forString(code).getCode(); | |||||
try { | |||||
return FormulaError.forString(code).getCode(); | |||||
} catch (final IllegalArgumentException e) { | |||||
throw new IllegalStateException("Unexpected error code", e); | |||||
} | |||||
} | } | ||||
/** | /** |
import org.apache.poi.ss.usermodel.IndexedColors; | import org.apache.poi.ss.usermodel.IndexedColors; | ||||
import org.apache.poi.ss.usermodel.VerticalAlignment; | import org.apache.poi.ss.usermodel.VerticalAlignment; | ||||
import org.apache.poi.util.Internal; | import org.apache.poi.util.Internal; | ||||
import org.apache.poi.util.Removal; | |||||
import org.apache.poi.xssf.model.StylesTable; | import org.apache.poi.xssf.model.StylesTable; | ||||
import org.apache.poi.xssf.model.ThemesTable; | import org.apache.poi.xssf.model.ThemesTable; | ||||
import org.apache.poi.xssf.usermodel.extensions.XSSFCellAlignment; | import org.apache.poi.xssf.usermodel.extensions.XSSFCellAlignment; | ||||
/** | /** | ||||
* Get the type of border to use for the bottom border of the cell | * Get the type of border to use for the bottom border of the cell | ||||
* Will be removed when {@link #getBorderBottom()} returns a BorderStyle enum | |||||
* | * | ||||
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | * @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public BorderStyle getBorderBottom() { | |||||
public BorderStyle getBorderBottomEnum() { | |||||
if(!_cellXf.getApplyBorder()) return BorderStyle.NONE; | if(!_cellXf.getApplyBorder()) return BorderStyle.NONE; | ||||
int idx = (int)_cellXf.getBorderId(); | int idx = (int)_cellXf.getBorderId(); | ||||
} | } | ||||
return BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | return BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | ||||
} | } | ||||
/** | /** | ||||
* Get the type of border to use for the bottom border of the cell | * Get the type of border to use for the bottom border of the cell | ||||
* This will return a BorderStyle enum in the future. | |||||
* | * | ||||
* @return border type as Java enum | |||||
* @deprecated 3.15 beta 2. Use {@link #getBorderBottom} | |||||
* @return border type code | |||||
* @deprecated 3.15 beta 2. Use {@link #getBorderBottomEnum()} | |||||
*/ | */ | ||||
public BorderStyle getBorderBottomEnum() { | |||||
return getBorderBottom(); | |||||
public short getBorderBottom() { | |||||
return getBorderBottomEnum().getCode(); | |||||
} | } | ||||
/** | /** | ||||
* Get the type of border to use for the left border of the cell | * Get the type of border to use for the left border of the cell | ||||
* Will be removed when {@link #getBorderLeft()} returns a BorderStyle enum | |||||
* | * | ||||
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | * @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public BorderStyle getBorderLeft() { | |||||
public BorderStyle getBorderLeftEnum() { | |||||
if(!_cellXf.getApplyBorder()) return BorderStyle.NONE; | if(!_cellXf.getApplyBorder()) return BorderStyle.NONE; | ||||
int idx = (int)_cellXf.getBorderId(); | int idx = (int)_cellXf.getBorderId(); | ||||
/** | /** | ||||
* Get the type of border to use for the left border of the cell | * Get the type of border to use for the left border of the cell | ||||
* This will return a BorderStyle enum in the future. | |||||
* | * | ||||
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | |||||
* @deprecated 3.15 beta 2. Use {@link #getBorderLeft} | |||||
* @return border type code | |||||
* @deprecated 3.15 beta 2. Use {@link #getBorderLeftEnum()} | |||||
*/ | */ | ||||
public BorderStyle getBorderLeftEnum() { | |||||
return getBorderLeft(); | |||||
public short getBorderLeft() { | |||||
return getBorderLeftEnum().getCode(); | |||||
} | } | ||||
/** | /** | ||||
* Get the type of border to use for the right border of the cell | * Get the type of border to use for the right border of the cell | ||||
* Will be removed when {@link #getBorderRight()} returns a BorderStyle enum | |||||
* | * | ||||
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | * @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public BorderStyle getBorderRight() { | |||||
public BorderStyle getBorderRightEnum() { | |||||
if(!_cellXf.getApplyBorder()) return BorderStyle.NONE; | if(!_cellXf.getApplyBorder()) return BorderStyle.NONE; | ||||
int idx = (int)_cellXf.getBorderId(); | int idx = (int)_cellXf.getBorderId(); | ||||
} | } | ||||
return BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | return BorderStyle.valueOf((short)(ptrn.intValue() - 1)); | ||||
} | } | ||||
/** | /** | ||||
* Get the type of border to use for the right border of the cell | * Get the type of border to use for the right border of the cell | ||||
* This will return a BorderStyle enum in the future. | |||||
* | * | ||||
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | * @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | ||||
* @deprecated 3.15 beta 2. Use {@link #getBorderRight} | |||||
* @deprecated 3.15 beta 2. Use {@link #getBorderRightEnum()} instead | |||||
*/ | */ | ||||
public BorderStyle getBorderRightEnum() { | |||||
return getBorderRight(); | |||||
public short getBorderRight() { | |||||
return getBorderRightEnum().getCode(); | |||||
} | } | ||||
/** | /** | ||||
* Get the type of border to use for the top border of the cell | * Get the type of border to use for the top border of the cell | ||||
* Will be removed when {@link #getBorderTop()} returns a BorderStyle enum | |||||
* | * | ||||
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | * @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public BorderStyle getBorderTop() { | |||||
public BorderStyle getBorderTopEnum() { | |||||
if(!_cellXf.getApplyBorder()) return BorderStyle.NONE; | if(!_cellXf.getApplyBorder()) return BorderStyle.NONE; | ||||
int idx = (int)_cellXf.getBorderId(); | int idx = (int)_cellXf.getBorderId(); | ||||
} | } | ||||
return BorderStyle.valueOf((short) (ptrn.intValue() - 1)); | return BorderStyle.valueOf((short) (ptrn.intValue() - 1)); | ||||
} | } | ||||
/** | /** | ||||
* Get the type of border to use for the top border of the cell | * Get the type of border to use for the top border of the cell | ||||
* This will return a BorderStyle enum in the future. | |||||
* | * | ||||
* @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | * @return border type, default value is {@link org.apache.poi.ss.usermodel.BorderStyle#NONE} | ||||
* @deprecated 3.15 beta 2. Use {@link #getBorderTop} | |||||
* @deprecated 3.15 beta 2. Use {@link #getBorderTopEnum()} instead. | |||||
*/ | */ | ||||
public BorderStyle getBorderTopEnum() { | |||||
return getBorderTop(); | |||||
public short getBorderTop() { | |||||
return getBorderTopEnum().getCode(); | |||||
} | } | ||||
/** | /** | ||||
* @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION | * @see org.apache.poi.ss.usermodel.CellStyle#ALIGN_CENTER_SELECTION | ||||
* @deprecated POI 3.15 beta 3. Use {@link #setAlignment(HorizontalAlignment)} instead. | * @deprecated POI 3.15 beta 3. Use {@link #setAlignment(HorizontalAlignment)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setAlignment(short align) { | public void setAlignment(short align) { | ||||
setAlignment(HorizontalAlignment.forInt(align)); | setAlignment(HorizontalAlignment.forInt(align)); | ||||
* @param border the type of border to use | * @param border the type of border to use | ||||
* @deprecated 3.15 beta 2. Use {@link #setBorderBottom(BorderStyle)} | * @deprecated 3.15 beta 2. Use {@link #setBorderBottom(BorderStyle)} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setBorderBottom(short border) { | public void setBorderBottom(short border) { | ||||
setBorderBottom(BorderStyle.valueOf(border)); | setBorderBottom(BorderStyle.valueOf(border)); | ||||
* | * | ||||
* @param border - type of border to use | * @param border - type of border to use | ||||
* @see org.apache.poi.ss.usermodel.BorderStyle | * @see org.apache.poi.ss.usermodel.BorderStyle | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public void setBorderBottom(BorderStyle border) { | public void setBorderBottom(BorderStyle border) { | ||||
* @param border the type of border to use | * @param border the type of border to use | ||||
* @deprecated 3.15 beta 2. Use {@link #setBorderLeft(BorderStyle)} | * @deprecated 3.15 beta 2. Use {@link #setBorderLeft(BorderStyle)} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setBorderLeft(short border) { | public void setBorderLeft(short border) { | ||||
setBorderLeft(BorderStyle.valueOf(border)); | setBorderLeft(BorderStyle.valueOf(border)); | ||||
* Set the type of border to use for the left border of the cell | * Set the type of border to use for the left border of the cell | ||||
* | * | ||||
* @param border the type of border to use | * @param border the type of border to use | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public void setBorderLeft(BorderStyle border) { | public void setBorderLeft(BorderStyle border) { | ||||
* @param border the type of border to use | * @param border the type of border to use | ||||
* @deprecated 3.15 beta 2. Use {@link #setBorderRight(BorderStyle)} | * @deprecated 3.15 beta 2. Use {@link #setBorderRight(BorderStyle)} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setBorderRight(short border) { | public void setBorderRight(short border) { | ||||
setBorderRight(BorderStyle.valueOf(border)); | setBorderRight(BorderStyle.valueOf(border)); | ||||
* Set the type of border to use for the right border of the cell | * Set the type of border to use for the right border of the cell | ||||
* | * | ||||
* @param border the type of border to use | * @param border the type of border to use | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public void setBorderRight(BorderStyle border) { | public void setBorderRight(BorderStyle border) { | ||||
* @param border the type of border to use | * @param border the type of border to use | ||||
* @deprecated 3.15 beta 2. Use {@link #setBorderTop(BorderStyle)} | * @deprecated 3.15 beta 2. Use {@link #setBorderTop(BorderStyle)} | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setBorderTop(short border) { | public void setBorderTop(short border) { | ||||
setBorderTop(BorderStyle.valueOf(border)); | setBorderTop(BorderStyle.valueOf(border)); | ||||
* Set the type of border to use for the top border of the cell | * Set the type of border to use for the top border of the cell | ||||
* | * | ||||
* @param border the type of border to use | * @param border the type of border to use | ||||
* @since POI 3.15 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public void setBorderTop(BorderStyle border) { | public void setBorderTop(BorderStyle border) { | ||||
* @see #setFillBackgroundColor(short) | * @see #setFillBackgroundColor(short) | ||||
* @see #setFillForegroundColor(short) | * @see #setFillForegroundColor(short) | ||||
* @param fp fill pattern (set to {@link org.apache.poi.ss.usermodel.CellStyle#SOLID_FOREGROUND} to fill w/foreground color) | * @param fp fill pattern (set to {@link org.apache.poi.ss.usermodel.CellStyle#SOLID_FOREGROUND} to fill w/foreground color) | ||||
* @deprecated POI 3.15. Use {@link #setFillPattern(FillPatternType)} instead. | |||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setFillPattern(short fp) { | public void setFillPattern(short fp) { | ||||
setFillPattern(FillPatternType.forInt(fp)); | setFillPattern(FillPatternType.forInt(fp)); | ||||
* @see org.apache.poi.ss.usermodel.VerticalAlignment | * @see org.apache.poi.ss.usermodel.VerticalAlignment | ||||
* @deprecated POI 3.15 beta 3. Use {@link #setVerticalAlignment(VerticalAlignment)} instead. | * @deprecated POI 3.15 beta 3. Use {@link #setVerticalAlignment(VerticalAlignment)} instead. | ||||
*/ | */ | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public void setVerticalAlignment(short align) { | public void setVerticalAlignment(short align) { | ||||
setVerticalAlignment(VerticalAlignment.forInt(align)); | setVerticalAlignment(VerticalAlignment.forInt(align)); |
import org.apache.poi.ss.usermodel.ClientAnchor; | import org.apache.poi.ss.usermodel.ClientAnchor; | ||||
import org.apache.poi.util.Internal; | import org.apache.poi.util.Internal; | ||||
import org.apache.poi.util.Removal; | |||||
import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker; | import org.openxmlformats.schemas.drawingml.x2006.spreadsheetDrawing.CTMarker; | ||||
/** | /** | ||||
/** | /** | ||||
* Sets the anchor type | * Sets the anchor type | ||||
* @param anchorType the anchor type to set | * @param anchorType the anchor type to set | ||||
* @since POI 3.14 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public void setAnchorType( AnchorType anchorType ) | public void setAnchorType( AnchorType anchorType ) | ||||
{ | { | ||||
this.anchorType = anchorType; | this.anchorType = anchorType; | ||||
} | } | ||||
/** | |||||
* Sets the anchor type | |||||
* @param anchorType the anchor type to set | |||||
* @deprecated POI 3.15. Use {@link #setAnchorType(AnchorType)} instead | |||||
*/ | |||||
@Removal(version="3.17") | |||||
@Override | |||||
public void setAnchorType( int anchorType ) | |||||
{ | |||||
this.anchorType = AnchorType.byId(anchorType); | |||||
} | |||||
/** | /** | ||||
* Gets the anchor type | * Gets the anchor type | ||||
* Changed from returning an int to an enum in POI 3.14 beta 1. | |||||
* @return the anchor type | * @return the anchor type | ||||
*/ | */ | ||||
@Override | @Override |
import org.apache.poi.ss.usermodel.CreationHelper; | import org.apache.poi.ss.usermodel.CreationHelper; | ||||
import org.apache.poi.ss.usermodel.Hyperlink; | import org.apache.poi.ss.usermodel.Hyperlink; | ||||
import org.apache.poi.util.Internal; | import org.apache.poi.util.Internal; | ||||
import org.apache.poi.util.Removal; | |||||
public class XSSFCreationHelper implements CreationHelper { | public class XSSFCreationHelper implements CreationHelper { | ||||
private final XSSFWorkbook workbook; | private final XSSFWorkbook workbook; | ||||
* @deprecated POI 3.15 beta 3. Use {@link #createHyperlink(HyperlinkType)} instead. | * @deprecated POI 3.15 beta 3. Use {@link #createHyperlink(HyperlinkType)} instead. | ||||
*/ | */ | ||||
@Deprecated | @Deprecated | ||||
@Removal(version="3.17") | |||||
@Override | @Override | ||||
public XSSFHyperlink createHyperlink(int type) { | public XSSFHyperlink createHyperlink(int type) { | ||||
return new XSSFHyperlink(type); | return new XSSFHyperlink(type); |
* For forwards compatibility, do not hard-code cell type literals in your code. | * For forwards compatibility, do not hard-code cell type literals in your code. | ||||
* | * | ||||
* @return cell type | * @return cell type | ||||
* @deprecated 3.15. Will return a {@link CellType} enum in the future. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public int getCellType() { | public int getCellType() { | ||||
* @deprecated 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 be deleted when we make the CellType enum transition. See bug 59791. | ||||
*/ | */ | ||||
@Internal(since="POI 3.15 beta 3") | |||||
@Override | @Override | ||||
public CellType getCellTypeEnum() { | public CellType getCellTypeEnum() { | ||||
return _cell.getCellTypeEnum(); | return _cell.getCellTypeEnum(); |
} | } | ||||
} | } | ||||
return _cellCache.get(new CellKey(rowIndex, columnIndex)); | |||||
final CellKey key = new CellKey(rowIndex, columnIndex); | |||||
EvaluationCell evalcell = _cellCache.get(key); | |||||
// If cache is stale, update cache with this one cell | |||||
// This is a compromise between rebuilding the entire cache | |||||
// (which would quickly defeat the benefit of the cache) | |||||
// and not caching at all. | |||||
// See bug 59958: Add cells on the fly to the evaluation sheet cache on cache miss | |||||
if (evalcell == null) { | |||||
XSSFRow row = _xs.getRow(rowIndex); | |||||
if (row == null) { | |||||
return null; | |||||
} | |||||
XSSFCell cell = row.getCell(columnIndex); | |||||
if (cell == null) { | |||||
return null; | |||||
} | |||||
evalcell = new XSSFEvaluationCell(cell, this); | |||||
_cellCache.put(key, evalcell); | |||||
} | |||||
return evalcell; | |||||
} | } | ||||
private static class CellKey { | private static class CellKey { |
import org.apache.poi.ss.formula.WorkbookEvaluator; | import org.apache.poi.ss.formula.WorkbookEvaluator; | ||||
import org.apache.poi.ss.formula.udf.UDFFinder; | import org.apache.poi.ss.formula.udf.UDFFinder; | ||||
import org.apache.poi.ss.usermodel.Cell; | import org.apache.poi.ss.usermodel.Cell; | ||||
import org.apache.poi.ss.usermodel.CellType; | |||||
import org.apache.poi.ss.usermodel.CellValue; | |||||
/** | /** | ||||
* Evaluates formula cells.<p/> | * Evaluates formula cells.<p/> | ||||
return new XSSFFormulaEvaluator(workbook, stabilityClassifier, udfFinder); | return new XSSFFormulaEvaluator(workbook, stabilityClassifier, udfFinder); | ||||
} | } | ||||
/** | |||||
* If cell contains formula, it evaluates the formula, and | |||||
* puts the formula result back into the cell, in place | |||||
* of the old formula. | |||||
* Else if cell does not contain formula, this method leaves | |||||
* the cell unchanged. | |||||
* Note that the same instance of XSSFCell is returned to | |||||
* allow chained calls like: | |||||
* <pre> | |||||
* int evaluatedCellType = evaluator.evaluateInCell(cell).getCellType(); | |||||
* </pre> | |||||
* Be aware that your cell value will be changed to hold the | |||||
* result of the formula. If you simply want the formula | |||||
* value computed for you, use {@link #evaluateFormulaCellEnum(org.apache.poi.ss.usermodel.Cell)} } | |||||
* @param cell | |||||
*/ | |||||
public XSSFCell evaluateInCell(Cell cell) { | |||||
doEvaluateInCell(cell); | |||||
return (XSSFCell)cell; | |||||
} | |||||
/** | /** | ||||
* Loops over all cells in all sheets of the supplied | * Loops over all cells in all sheets of the supplied | ||||
* workbook. | * workbook. | ||||
public static void evaluateAllFormulaCells(XSSFWorkbook wb) { | public static void evaluateAllFormulaCells(XSSFWorkbook wb) { | ||||
BaseFormulaEvaluator.evaluateAllFormulaCells(wb); | BaseFormulaEvaluator.evaluateAllFormulaCells(wb); | ||||
} | } | ||||
@Override | |||||
public XSSFCell evaluateInCell(Cell cell) { | |||||
return (XSSFCell) super.evaluateInCell(cell); | |||||
} | |||||
/** | /** | ||||
* Loops over all cells in all sheets of the supplied | * Loops over all cells in all sheets of the supplied | ||||
* workbook. | * workbook. |
* @return the type of this hyperlink | * @return the type of this hyperlink | ||||
* @see HyperlinkType#forInt | * @see HyperlinkType#forInt | ||||
* @deprecated POI 3.15 beta 3. Use {@link #getTypeEnum()} instead. | * @deprecated POI 3.15 beta 3. Use {@link #getTypeEnum()} instead. | ||||
* getType will return a HyperlinkType enum in the future. | |||||
*/ | */ | ||||
@Override | @Override | ||||
public int getType() { | public int getType() { |
import org.apache.poi.POIXMLDocumentPart; | import org.apache.poi.POIXMLDocumentPart; | ||||
import org.apache.poi.openxml4j.opc.PackagePart; | import org.apache.poi.openxml4j.opc.PackagePart; | ||||
import org.apache.poi.openxml4j.opc.PackageRelationship; | import org.apache.poi.openxml4j.opc.PackageRelationship; | ||||
import org.apache.poi.ss.SpreadsheetVersion; | |||||
import org.apache.poi.ss.usermodel.Cell; | import org.apache.poi.ss.usermodel.Cell; | ||||
import org.apache.poi.ss.usermodel.CellType; | import org.apache.poi.ss.usermodel.CellType; | ||||
import org.apache.poi.ss.usermodel.DataConsolidateFunction; | import org.apache.poi.ss.usermodel.DataConsolidateFunction; | ||||
} | } | ||||
protected AreaReference getPivotArea() { | protected AreaReference getPivotArea() { | ||||
AreaReference pivotArea = new AreaReference(getPivotCacheDefinition(). | |||||
getCTPivotCacheDefinition().getCacheSource().getWorksheetSource().getRef()); | |||||
AreaReference pivotArea = new AreaReference( | |||||
getPivotCacheDefinition() | |||||
.getCTPivotCacheDefinition() | |||||
.getCacheSource() | |||||
.getWorksheetSource() | |||||
.getRef(), | |||||
SpreadsheetVersion.EXCEL2007); | |||||
return pivotArea; | return pivotArea; | ||||
} | } | ||||
/** | |||||
* Verify column index (relative to first column in pivot area) is within the | |||||
* pivot area | |||||
* | |||||
* @param columnIndex | |||||
* @throws IndexOutOfBoundsException | |||||
*/ | |||||
private void checkColumnIndex(int columnIndex) throws IndexOutOfBoundsException { | |||||
AreaReference pivotArea = getPivotArea(); | |||||
int size = pivotArea.getLastCell().getCol() - pivotArea.getFirstCell().getCol() + 1; | |||||
if (columnIndex < 0 || columnIndex >= size) { | |||||
throw new IndexOutOfBoundsException("Column Index: " + columnIndex + ", Size: " + size); | |||||
} | |||||
} | |||||
/** | /** | ||||
* Add a row label using data from the given column. | * Add a row label using data from the given column. | ||||
* @param columnIndex the index of the column to be used as row label. | |||||
* @param columnIndex the index of the source column to be used as row label. | |||||
* {@code columnIndex} is 0-based indexed and relative to the first column in the source. | |||||
*/ | */ | ||||
@Beta | @Beta | ||||
public void addRowLabel(int columnIndex) { | public void addRowLabel(int columnIndex) { | ||||
checkColumnIndex(columnIndex); | |||||
AreaReference pivotArea = getPivotArea(); | AreaReference pivotArea = getPivotArea(); | ||||
int lastRowIndex = pivotArea.getLastCell().getRow() - pivotArea.getFirstCell().getRow(); | |||||
int lastColIndex = pivotArea.getLastCell().getCol() - pivotArea.getFirstCell().getCol(); | |||||
if(columnIndex > lastColIndex) { | |||||
throw new IndexOutOfBoundsException(); | |||||
} | |||||
final int lastRowIndex = pivotArea.getLastCell().getRow() - pivotArea.getFirstCell().getRow(); | |||||
CTPivotFields pivotFields = pivotTableDefinition.getPivotFields(); | CTPivotFields pivotFields = pivotTableDefinition.getPivotFields(); | ||||
CTPivotField pivotField = CTPivotField.Factory.newInstance(); | CTPivotField pivotField = CTPivotField.Factory.newInstance(); | ||||
pivotField.setAxis(STAxis.AXIS_ROW); | pivotField.setAxis(STAxis.AXIS_ROW); | ||||
pivotField.setShowAll(false); | pivotField.setShowAll(false); | ||||
for(int i = 0; i <= lastRowIndex; i++) { | |||||
for (int i = 0; i <= lastRowIndex; i++) { | |||||
items.addNewItem().setT(STItemType.DEFAULT); | items.addNewItem().setT(STItemType.DEFAULT); | ||||
} | } | ||||
items.setCount(items.sizeOfItemArray()); | items.setCount(items.sizeOfItemArray()); | ||||
/** | /** | ||||
* Add a column label using data from the given column and specified function | * 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 columnIndex the index of the source column to be used as column label. | |||||
* {@code columnIndex} is 0-based indexed and relative to the first column in the source. | |||||
* @param function the function to be used on the data | * @param function the function to be used on the data | ||||
* The following functions exists: | * The following functions exists: | ||||
* Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, Varp | * Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, Varp | ||||
*/ | */ | ||||
@Beta | @Beta | ||||
public void addColumnLabel(DataConsolidateFunction function, int columnIndex, String valueFieldName) { | public void addColumnLabel(DataConsolidateFunction function, int columnIndex, String valueFieldName) { | ||||
AreaReference pivotArea = getPivotArea(); | |||||
int lastColIndex = pivotArea.getLastCell().getCol() - pivotArea.getFirstCell().getCol(); | |||||
if(columnIndex > lastColIndex && columnIndex < 0) { | |||||
throw new IndexOutOfBoundsException(); | |||||
} | |||||
checkColumnIndex(columnIndex); | |||||
addDataColumn(columnIndex, true); | addDataColumn(columnIndex, true); | ||||
addDataField(function, columnIndex, valueFieldName); | addDataField(function, columnIndex, valueFieldName); | ||||
/** | /** | ||||
* Add a column label using data from the given column and specified function | * 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 columnIndex the index of the source column to be used as column label | |||||
* {@code columnIndex} is 0-based indexed and relative to the first column in the source.. | |||||
* @param function the function to be used on the data | * @param function the function to be used on the data | ||||
* The following functions exists: | * The following functions exists: | ||||
* Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, Varp | * Sum, Count, Average, Max, Min, Product, Count numbers, StdDev, StdDevp, Var, Varp | ||||
*/ | */ | ||||
@Beta | @Beta | ||||
private void addDataField(DataConsolidateFunction function, int columnIndex, String valueFieldName) { | private void addDataField(DataConsolidateFunction function, int columnIndex, String valueFieldName) { | ||||
checkColumnIndex(columnIndex); | |||||
AreaReference pivotArea = getPivotArea(); | AreaReference pivotArea = getPivotArea(); | ||||
int lastColIndex = pivotArea.getLastCell().getCol() - pivotArea.getFirstCell().getCol(); | |||||
if(columnIndex > lastColIndex && columnIndex < 0) { | |||||
throw new IndexOutOfBoundsException(); | |||||
} | |||||
CTDataFields dataFields; | CTDataFields dataFields; | ||||
if(pivotTableDefinition.getDataFields() != null) { | if(pivotTableDefinition.getDataFields() != null) { | ||||
dataFields = pivotTableDefinition.getDataFields(); | dataFields = pivotTableDefinition.getDataFields(); | ||||
*/ | */ | ||||
@Beta | @Beta | ||||
public void addDataColumn(int columnIndex, boolean isDataField) { | public void addDataColumn(int columnIndex, boolean isDataField) { | ||||
AreaReference pivotArea = getPivotArea(); | |||||
int lastColIndex = pivotArea.getLastCell().getCol() - pivotArea.getFirstCell().getCol(); | |||||
if(columnIndex > lastColIndex && columnIndex < 0) { | |||||
throw new IndexOutOfBoundsException(); | |||||
} | |||||
checkColumnIndex(columnIndex); | |||||
CTPivotFields pivotFields = pivotTableDefinition.getPivotFields(); | CTPivotFields pivotFields = pivotTableDefinition.getPivotFields(); | ||||
CTPivotField pivotField = CTPivotField.Factory.newInstance(); | CTPivotField pivotField = CTPivotField.Factory.newInstance(); | ||||
*/ | */ | ||||
@Beta | @Beta | ||||
public void addReportFilter(int columnIndex) { | public void addReportFilter(int columnIndex) { | ||||
checkColumnIndex(columnIndex); | |||||
AreaReference pivotArea = getPivotArea(); | AreaReference pivotArea = getPivotArea(); | ||||
int lastColIndex = pivotArea.getLastCell().getCol() - pivotArea.getFirstCell().getCol(); | |||||
int lastRowIndex = pivotArea.getLastCell().getRow() - pivotArea.getFirstCell().getRow(); | int lastRowIndex = pivotArea.getLastCell().getRow() - pivotArea.getFirstCell().getRow(); | ||||
if(columnIndex > lastColIndex && columnIndex < 0) { | |||||
throw new IndexOutOfBoundsException(); | |||||
} | |||||
CTPivotFields pivotFields = pivotTableDefinition.getPivotFields(); | CTPivotFields pivotFields = pivotTableDefinition.getPivotFields(); | ||||
CTPivotField pivotField = CTPivotField.Factory.newInstance(); | CTPivotField pivotField = CTPivotField.Factory.newInstance(); |
} | } | ||||
} else { | } else { | ||||
//search the referenced drawing in the list of the sheet's relations | //search the referenced drawing in the list of the sheet's relations | ||||
final String id = ctDrawing.getId(); | |||||
for (RelationPart rp : getRelationParts()){ | for (RelationPart rp : getRelationParts()){ | ||||
POIXMLDocumentPart p = rp.getDocumentPart(); | POIXMLDocumentPart p = rp.getDocumentPart(); | ||||
if(p instanceof XSSFVMLDrawing) { | if(p instanceof XSSFVMLDrawing) { | ||||
XSSFVMLDrawing dr = (XSSFVMLDrawing)p; | XSSFVMLDrawing dr = (XSSFVMLDrawing)p; | ||||
String drId = rp.getRelationship().getId(); | String drId = rp.getRelationship().getId(); | ||||
if(drId.equals(ctDrawing.getId())){ | |||||
if (drId.equals(id)) { | |||||
drawing = dr; | drawing = dr; | ||||
break; | break; | ||||
} | } | ||||
break; | |||||
// do not break here since drawing has not been found yet (see bug 52425) | |||||
} | } | ||||
} | } | ||||
if(drawing == null){ | if(drawing == null){ | ||||
logger.log(POILogger.ERROR, "Can't find VML drawing with id=" + ctDrawing.getId() + " in the list of the sheet's relationships"); | |||||
logger.log(POILogger.ERROR, "Can't find VML drawing with id=" + id + " in the list of the sheet's relationships"); | |||||
} | } | ||||
} | } | ||||
return drawing; | return drawing; | ||||
* @return The pivot table | * @return The pivot table | ||||
*/ | */ | ||||
@Beta | @Beta | ||||
public XSSFPivotTable createPivotTable(AreaReference source, CellReference position, Sheet sourceSheet){ | |||||
if(source.getFirstCell().getSheetName() != null && !source.getFirstCell().getSheetName().equals(sourceSheet.getSheetName())) { | |||||
public XSSFPivotTable createPivotTable(AreaReference source, CellReference position, Sheet sourceSheet) { | |||||
final String sourceSheetName = source.getFirstCell().getSheetName(); | |||||
if(sourceSheetName != null && !sourceSheetName.equalsIgnoreCase(sourceSheet.getSheetName())) { | |||||
throw new IllegalArgumentException("The area is referenced in another sheet than the " | throw new IllegalArgumentException("The area is referenced in another sheet than the " | ||||
+ "defined source sheet " + sourceSheet.getSheetName() + "."); | + "defined source sheet " + sourceSheet.getSheetName() + "."); | ||||
} | } | ||||
*/ | */ | ||||
@Beta | @Beta | ||||
public XSSFPivotTable createPivotTable(AreaReference source, CellReference position){ | public XSSFPivotTable createPivotTable(AreaReference source, CellReference position){ | ||||
if(source.getFirstCell().getSheetName() != null && !source.getFirstCell().getSheetName().equals(this.getSheetName())) { | |||||
return createPivotTable(source, position, getWorkbook().getSheet(source.getFirstCell().getSheetName())); | |||||
final String sourceSheetName = source.getFirstCell().getSheetName(); | |||||
if(sourceSheetName != null && !sourceSheetName.equalsIgnoreCase(this.getSheetName())) { | |||||
final XSSFSheet sourceSheet = getWorkbook().getSheet(sourceSheetName); | |||||
return createPivotTable(source, position, sourceSheet); | |||||
} | } | ||||
return createPivotTable(source, position, this); | return createPivotTable(source, position, this); | ||||
} | } |
import static org.junit.Assert.assertNotNull; | import static org.junit.Assert.assertNotNull; | ||||
import static org.junit.Assert.assertNull; | import static org.junit.Assert.assertNull; | ||||
import static org.junit.Assert.assertSame; | import static org.junit.Assert.assertSame; | ||||
import static org.junit.Assert.fail; | |||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileOutputStream; | import java.io.FileOutputStream; | ||||
import java.util.List; | import java.util.List; | ||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; | import org.apache.poi.openxml4j.exceptions.InvalidFormatException; | ||||
import org.apache.poi.openxml4j.exceptions.OpenXML4JRuntimeException; | |||||
import org.apache.poi.openxml4j.opc.OPCPackage; | import org.apache.poi.openxml4j.opc.OPCPackage; | ||||
import org.apache.poi.openxml4j.opc.PackagePart; | import org.apache.poi.openxml4j.opc.PackagePart; | ||||
import org.apache.poi.openxml4j.opc.PackageRelationshipTypes; | import org.apache.poi.openxml4j.opc.PackageRelationshipTypes; | ||||
import org.apache.poi.util.NullOutputStream; | |||||
import org.apache.poi.util.PackageHelper; | import org.apache.poi.util.PackageHelper; | ||||
import org.apache.poi.util.TempFile; | import org.apache.poi.util.TempFile; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
FileOutputStream out = new FileOutputStream(tmp); | FileOutputStream out = new FileOutputStream(tmp); | ||||
doc.write(out); | doc.write(out); | ||||
out.close(); | out.close(); | ||||
// Should not be able to write to an output stream that has been closed | |||||
try { | |||||
doc.write(out); | |||||
fail("Should not be able to write to an output stream that has been closed."); | |||||
} catch (final OpenXML4JRuntimeException e) { | |||||
// FIXME: A better exception class (IOException?) and message should be raised | |||||
// indicating that the document could not be written because the output stream is closed. | |||||
// see {@link org.apache.poi.openxml4j.opc.ZipPackage#saveImpl(java.io.OutputStream)} | |||||
if (e.getMessage().matches("Fail to save: an error occurs while saving the package : The part .+ fail to be saved in the stream with marshaller .+")) { | |||||
// expected | |||||
} else { | |||||
throw e; | |||||
} | |||||
} | |||||
// Should not be able to write a document that has been closed | |||||
doc.close(); | doc.close(); | ||||
try { | |||||
doc.write(new NullOutputStream()); | |||||
fail("Should not be able to write a document that has been closed."); | |||||
} catch (final IOException e) { | |||||
if (e.getMessage().equals("Cannot write data, document seems to have been closed already")) { | |||||
// expected | |||||
} else { | |||||
throw e; | |||||
} | |||||
} | |||||
// Should be able to close a document multiple times, though subsequent closes will have no effect. | |||||
doc.close(); | |||||
@SuppressWarnings("resource") | @SuppressWarnings("resource") | ||||
OPCPackage pkg2 = OPCPackage.open(tmp.getAbsolutePath()); | OPCPackage pkg2 = OPCPackage.open(tmp.getAbsolutePath()); | ||||
doc = new OPCParser(pkg1); | |||||
try { | try { | ||||
doc = new OPCParser(pkg1); | |||||
doc.parse(new TestFactory()); | doc.parse(new TestFactory()); | ||||
context = new HashMap<String,POIXMLDocumentPart>(); | context = new HashMap<String,POIXMLDocumentPart>(); | ||||
traverse(doc, context); | traverse(doc, context); | ||||
} | } | ||||
} finally { | } finally { | ||||
doc.close(); | doc.close(); | ||||
pkg1.close(); | |||||
pkg2.close(); | pkg2.close(); | ||||
} | } | ||||
} | } |
// Text | // Text | ||||
try { | try { | ||||
ExtractorFactory.createExtractor(OPCPackage.open(txt.toString())); | ExtractorFactory.createExtractor(OPCPackage.open(txt.toString())); | ||||
fail(); | |||||
fail("TestExtractorFactory.testPackage() failed on " + txt.toString()); | |||||
} catch(UnsupportedFileFormatException e) { | } catch(UnsupportedFileFormatException e) { | ||||
// Good | // Good | ||||
} catch (Exception e) { | |||||
System.out.println("TestExtractorFactory.testPackage() failed on " + txt.toString()); | |||||
throw e; | |||||
} | } | ||||
} | } | ||||
"openxml4j/OPCCompliance_CoreProperties_OnlyOneCorePropertiesPartFAIL.docx", | "openxml4j/OPCCompliance_CoreProperties_OnlyOneCorePropertiesPartFAIL.docx", | ||||
"openxml4j/OPCCompliance_CoreProperties_UnauthorizedXMLLangAttributeFAIL.docx", | "openxml4j/OPCCompliance_CoreProperties_UnauthorizedXMLLangAttributeFAIL.docx", | ||||
"openxml4j/OPCCompliance_DerivedPartNameFAIL.docx", | "openxml4j/OPCCompliance_DerivedPartNameFAIL.docx", | ||||
"openxml4j/invalid.xlsx", | |||||
"spreadsheet/54764-2.xlsx", // see TestXSSFBugs.bug54764() | "spreadsheet/54764-2.xlsx", // see TestXSSFBugs.bug54764() | ||||
"spreadsheet/54764.xlsx", // see TestXSSFBugs.bug54764() | "spreadsheet/54764.xlsx", // see TestXSSFBugs.bug54764() | ||||
"spreadsheet/Simple.xlsb", | "spreadsheet/Simple.xlsb", |
ZipSecureFile.setMaxTextSize(before); | ZipSecureFile.setMaxTextSize(before); | ||||
} | } | ||||
} | } | ||||
// bug 60128 | |||||
@Test | |||||
public void testCorruptFile() throws IOException { | |||||
OPCPackage pkg = null; | |||||
File file = OpenXML4JTestDataSamples.getSampleFile("invalid.xlsx"); | |||||
try { | |||||
pkg = OPCPackage.open(file, PackageAccess.READ); | |||||
} catch (Exception e) { | |||||
System.out.println(e.getClass().getName()); | |||||
System.out.println(e.getMessage()); | |||||
e.printStackTrace(); | |||||
} finally { | |||||
if (pkg != null) { | |||||
pkg.close(); | |||||
} | |||||
} | |||||
} | |||||
} | } |
import java.io.PrintWriter; | import java.io.PrintWriter; | ||||
import java.io.UnsupportedEncodingException; | import java.io.UnsupportedEncodingException; | ||||
import org.apache.poi.POIDataSamples; | |||||
import org.apache.poi.POITextExtractor; | import org.apache.poi.POITextExtractor; | ||||
import org.apache.poi.POIXMLException; | import org.apache.poi.POIXMLException; | ||||
import org.apache.poi.extractor.ExtractorFactory; | import org.apache.poi.extractor.ExtractorFactory; | ||||
import org.apache.poi.hssf.HSSFTestDataSamples; | import org.apache.poi.hssf.HSSFTestDataSamples; | ||||
import org.apache.poi.openxml4j.OpenXML4JTestDataSamples; | import org.apache.poi.openxml4j.OpenXML4JTestDataSamples; | ||||
import org.apache.poi.openxml4j.exceptions.NotOfficeXmlFileException; | |||||
import org.apache.poi.openxml4j.exceptions.ODFNotOfficeXmlFileException; | |||||
import org.apache.poi.sl.usermodel.SlideShow; | import org.apache.poi.sl.usermodel.SlideShow; | ||||
import org.apache.poi.sl.usermodel.SlideShowFactory; | import org.apache.poi.sl.usermodel.SlideShowFactory; | ||||
import org.apache.poi.ss.usermodel.Workbook; | import org.apache.poi.ss.usermodel.Workbook; | ||||
public void testClosingStreamOnException() throws IOException { | public void testClosingStreamOnException() throws IOException { | ||||
InputStream is = OpenXML4JTestDataSamples.openSampleStream("dcterms_bug_56479.zip"); | InputStream is = OpenXML4JTestDataSamples.openSampleStream("dcterms_bug_56479.zip"); | ||||
File tmp = File.createTempFile("poi-test-truncated-zip", ""); | File tmp = File.createTempFile("poi-test-truncated-zip", ""); | ||||
// create a corrupted zip file by truncating a valid zip file to the first 100 bytes | |||||
OutputStream os = new FileOutputStream(tmp); | OutputStream os = new FileOutputStream(tmp); | ||||
for (int i = 0; i < 100; i++) { | for (int i = 0; i < 100; i++) { | ||||
os.write(is.read()); | os.write(is.read()); | ||||
os.close(); | os.close(); | ||||
is.close(); | is.close(); | ||||
// feed the corrupted zip file to OPCPackage | |||||
try { | try { | ||||
OPCPackage.open(tmp, PackageAccess.READ); | OPCPackage.open(tmp, PackageAccess.READ); | ||||
} catch (Exception e) { | } catch (Exception e) { | ||||
// expected: the zip file is invalid | |||||
// this test does not care if open() throws an exception or not. | |||||
} | } | ||||
// If the stream is not closed on exception, it will keep a file descriptor to tmp, | |||||
// and requests to the OS to delete the file will fail. | |||||
assertTrue("Can't delete tmp file", tmp.delete()); | assertTrue("Can't delete tmp file", tmp.delete()); | ||||
} | |||||
/** | |||||
* If ZipPackage is passed an invalid file, a call to close | |||||
* (eg from the OPCPackage open method) should tidy up the | |||||
* stream / file the broken file is being read from. | |||||
* See bug #60128 for more | |||||
*/ | |||||
@Test | |||||
public void testTidyStreamOnInvalidFile() throws Exception { | |||||
// Spreadsheet has a good mix of alternate file types | |||||
POIDataSamples files = POIDataSamples.getSpreadSheetInstance(); | |||||
File[] notValidF = new File[] { | |||||
files.getFile("SampleSS.ods"), files.getFile("SampleSS.txt") | |||||
}; | |||||
InputStream[] notValidS = new InputStream[] { | |||||
files.openResourceAsStream("SampleSS.ods"), files.openResourceAsStream("SampleSS.txt") | |||||
}; | |||||
for (File notValid : notValidF) { | |||||
ZipPackage pkg = new ZipPackage(notValid, PackageAccess.READ); | |||||
assertNotNull(pkg.getZipArchive()); | |||||
assertFalse(pkg.getZipArchive().isClosed()); | |||||
try { | |||||
pkg.getParts(); | |||||
fail("Shouldn't work"); | |||||
} catch (ODFNotOfficeXmlFileException e) { | |||||
} catch (NotOfficeXmlFileException ne) {} | |||||
pkg.close(); | |||||
assertNotNull(pkg.getZipArchive()); | |||||
assertTrue(pkg.getZipArchive().isClosed()); | |||||
} | |||||
for (InputStream notValid : notValidS) { | |||||
ZipPackage pkg = new ZipPackage(notValid, PackageAccess.READ); | |||||
assertNotNull(pkg.getZipArchive()); | |||||
assertFalse(pkg.getZipArchive().isClosed()); | |||||
try { | |||||
pkg.getParts(); | |||||
fail("Shouldn't work"); | |||||
} catch (ODFNotOfficeXmlFileException e) { | |||||
} catch (NotOfficeXmlFileException ne) {} | |||||
pkg.close(); | |||||
assertNotNull(pkg.getZipArchive()); | |||||
assertTrue(pkg.getZipArchive().isClosed()); | |||||
} | |||||
} | } | ||||
} | } |
static class AesZipFileZipEntrySource implements ZipEntrySource { | static class AesZipFileZipEntrySource implements ZipEntrySource { | ||||
final ZipFile zipFile; | final ZipFile zipFile; | ||||
final Cipher ci; | final Cipher ci; | ||||
boolean closed; | |||||
AesZipFileZipEntrySource(ZipFile zipFile, Cipher ci) { | AesZipFileZipEntrySource(ZipFile zipFile, Cipher ci) { | ||||
this.zipFile = zipFile; | this.zipFile = zipFile; | ||||
this.ci = ci; | this.ci = ci; | ||||
this.closed = false; | |||||
} | } | ||||
/** | /** | ||||
@Override | @Override | ||||
public void close() throws IOException { | public void close() throws IOException { | ||||
zipFile.close(); | zipFile.close(); | ||||
closed = true; | |||||
} | |||||
@Override | |||||
public boolean isClosed() { | |||||
return closed; | |||||
} | } | ||||
} | } | ||||
} | } |
private static void confirm(FormulaEvaluator fe, Cell cell, double expectedResult) { | private static void confirm(FormulaEvaluator fe, Cell cell, double expectedResult) { | ||||
fe.clearAllCachedResultValues(); | fe.clearAllCachedResultValues(); | ||||
CellValue cv = fe.evaluate(cell); | CellValue cv = fe.evaluate(cell); | ||||
if (cv.getCellType() != CellType.NUMERIC) { | |||||
if (cv.getCellTypeEnum() != CellType.NUMERIC) { | |||||
fail("expected numeric cell type but got " + cv.formatAsString()); | fail("expected numeric cell type but got " + cv.formatAsString()); | ||||
} | } | ||||
assertEquals(expectedResult, cv.getNumberValue(), 0.0); | assertEquals(expectedResult, cv.getNumberValue(), 0.0); | ||||
private static void confirm(FormulaEvaluator fe, Cell cell, String expectedResult) { | private static void confirm(FormulaEvaluator fe, Cell cell, String expectedResult) { | ||||
fe.clearAllCachedResultValues(); | fe.clearAllCachedResultValues(); | ||||
CellValue cv = fe.evaluate(cell); | CellValue cv = fe.evaluate(cell); | ||||
if (cv.getCellType() != CellType.STRING) { | |||||
if (cv.getCellTypeEnum() != CellType.STRING) { | |||||
fail("expected String cell type but got " + cv.formatAsString()); | fail("expected String cell type but got " + cv.formatAsString()); | ||||
} | } | ||||
assertEquals(expectedResult, cv.getStringValue()); | assertEquals(expectedResult, cv.getStringValue()); |
cell11.setCellFormula(formulaText); | cell11.setCellFormula(formulaText); | ||||
evaluator.clearAllCachedResultValues(); | evaluator.clearAllCachedResultValues(); | ||||
CellValue cv = evaluator.evaluate(cell11); | CellValue cv = evaluator.evaluate(cell11); | ||||
if (cv.getCellType() != CellType.STRING) { | |||||
if (cv.getCellTypeEnum() != CellType.STRING) { | |||||
throw new AssertionFailedError("Wrong result type: " + cv.formatAsString()); | throw new AssertionFailedError("Wrong result type: " + cv.formatAsString()); | ||||
} | } | ||||
String actualValue = cv.getStringValue(); | String actualValue = cv.getStringValue(); |
/* ==================================================================== | |||||
Licensed to the Apache Software Foundation (ASF) under one or more | |||||
contributor license agreements. See the NOTICE file distributed with | |||||
this work for additional information regarding copyright ownership. | |||||
The ASF licenses this file to You under the Apache License, Version 2.0 | |||||
(the "License"); you may not use this file except in compliance with | |||||
the License. You may obtain a copy of the License at | |||||
http://www.apache.org/licenses/LICENSE-2.0 | |||||
Unless required by applicable law or agreed to in writing, software | |||||
distributed under the License is distributed on an "AS IS" BASIS, | |||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |||||
See the License for the specific language governing permissions and | |||||
limitations under the License. | |||||
==================================================================== */ | |||||
package org.apache.poi.xslf.usermodel; | |||||
import static org.junit.Assert.assertEquals; | |||||
import static org.junit.Assert.assertFalse; | |||||
import static org.junit.Assert.assertNotNull; | |||||
import static org.junit.Assert.assertSame; | |||||
import static org.junit.Assert.assertTrue; | |||||
import static org.junit.Assert.fail; | |||||
import java.io.IOException; | |||||
import java.util.List; | |||||
import org.apache.poi.xslf.XSLFTestDataSamples; | |||||
import org.junit.After; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableCell; | |||||
import org.openxmlformats.schemas.drawingml.x2006.main.CTTableRow; | |||||
public class TestXSLFTableRow { | |||||
private static XMLSlideShow ppt; | |||||
private static XSLFTable tbl; | |||||
private static XSLFTableRow row; | |||||
/** Copied from {@link TestXSLFTable#testRead()} */ | |||||
@Before | |||||
public void setUp() throws IOException { | |||||
ppt = XSLFTestDataSamples.openSampleDocument("shapes.pptx"); | |||||
XSLFSlide slide = ppt.getSlides().get(3); | |||||
List<XSLFShape> shapes = slide.getShapes(); | |||||
tbl = (XSLFTable)shapes.get(0); | |||||
List<XSLFTableRow> rows = tbl.getRows(); | |||||
row = rows.get(0); | |||||
} | |||||
@After | |||||
public void tearDown() throws IOException { | |||||
ppt.getPackage().revert(); | |||||
ppt.close(); | |||||
} | |||||
@Test | |||||
public void constructor() { | |||||
XSLFTableRow row2 = new XSLFTableRow(row.getXmlObject(), tbl); | |||||
assertSame(row.getXmlObject(), row2.getXmlObject()); | |||||
assertEquals(row.getHeight(), row2.getHeight(), 1e-16); | |||||
} | |||||
@Test | |||||
public void testHeight() { | |||||
final double h = 10.0; | |||||
row.setHeight(h); | |||||
assertEquals(h, row.getHeight(), 1e-16); | |||||
} | |||||
/** copied from {@link TestXSLFTable#testCreate()} */ | |||||
@Test | |||||
public void getCells() { | |||||
List<XSLFTableCell> cells = row.getCells(); | |||||
assertNotNull(cells); | |||||
assertEquals(3, cells.size()); | |||||
} | |||||
@Test | |||||
public void testIterator() { | |||||
int i = 0; | |||||
for (XSLFTableCell cell : row) { | |||||
i++; | |||||
assertEquals("header"+i, cell.getText()); | |||||
} | |||||
assertEquals(3, i); | |||||
} | |||||
/** copied from {@link TestXSLFTable#testCreate()} */ | |||||
@Test | |||||
public void addCell() { | |||||
XSLFTableCell cell = row.addCell(); | |||||
assertNotNull(cell); | |||||
assertNotNull(cell.getXmlObject()); | |||||
// by default table cell has no borders | |||||
CTTableCell tc = (CTTableCell)cell.getXmlObject(); | |||||
assertTrue(tc.getTcPr().getLnB().isSetNoFill()); | |||||
assertTrue(tc.getTcPr().getLnT().isSetNoFill()); | |||||
assertTrue(tc.getTcPr().getLnL().isSetNoFill()); | |||||
assertTrue(tc.getTcPr().getLnR().isSetNoFill()); | |||||
} | |||||
@Test | |||||
public void mergeCells() { | |||||
try { | |||||
row.mergeCells(0, 0); | |||||
fail("expected IllegalArgumentException when merging fewer than 2 columns"); | |||||
} catch (final IllegalArgumentException e) { | |||||
// expected | |||||
} | |||||
row.mergeCells(0, 1); | |||||
List<XSLFTableCell> cells = row.getCells(); | |||||
//the top-left cell of a merged region is not regarded as merged | |||||
assertFalse("top-left cell of merged region", cells.get(0).isMerged()); | |||||
assertTrue("inside merged region", cells.get(1).isMerged()); | |||||
assertFalse("outside merged region", cells.get(2).isMerged()); | |||||
} | |||||
@Test | |||||
public void getXmlObject() { | |||||
CTTableRow ctrow = row.getXmlObject(); | |||||
assertNotNull(ctrow); | |||||
} | |||||
} |
import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
import static org.junit.Assert.fail; | import static org.junit.Assert.fail; | ||||
import java.io.ByteArrayInputStream; | |||||
import java.io.ByteArrayOutputStream; | import java.io.ByteArrayOutputStream; | ||||
import java.io.File; | import java.io.File; | ||||
import java.io.FileInputStream; | import java.io.FileInputStream; | ||||
import org.apache.poi.POIDataSamples; | import org.apache.poi.POIDataSamples; | ||||
import org.apache.poi.POITestCase; | import org.apache.poi.POITestCase; | ||||
import org.apache.poi.openxml4j.exceptions.InvalidFormatException; | import org.apache.poi.openxml4j.exceptions.InvalidFormatException; | ||||
import org.apache.poi.openxml4j.opc.OPCPackage; | |||||
import org.apache.poi.openxml4j.opc.PackageAccess; | |||||
import org.apache.poi.ss.usermodel.BaseTestXWorkbook; | import org.apache.poi.ss.usermodel.BaseTestXWorkbook; | ||||
import org.apache.poi.ss.usermodel.Cell; | import org.apache.poi.ss.usermodel.Cell; | ||||
import org.apache.poi.ss.usermodel.CellType; | import org.apache.poi.ss.usermodel.CellType; | ||||
import org.apache.poi.ss.usermodel.Workbook; | import org.apache.poi.ss.usermodel.Workbook; | ||||
import org.apache.poi.ss.usermodel.WorkbookFactory; | import org.apache.poi.ss.usermodel.WorkbookFactory; | ||||
import org.apache.poi.ss.util.CellReference; | import org.apache.poi.ss.util.CellReference; | ||||
import org.apache.poi.util.NullOutputStream; | |||||
import org.apache.poi.xssf.SXSSFITestDataProvider; | import org.apache.poi.xssf.SXSSFITestDataProvider; | ||||
import org.apache.poi.xssf.XSSFTestDataSamples; | import org.apache.poi.xssf.XSSFTestDataSamples; | ||||
import org.apache.poi.xssf.model.SharedStringsTable; | import org.apache.poi.xssf.model.SharedStringsTable; | ||||
swb.dispose(); | swb.dispose(); | ||||
swb.close(); | swb.close(); | ||||
} | } | ||||
/** | |||||
* To avoid accident changes to the template, you should be able | |||||
* to create a SXSSFWorkbook from a read-only XSSF one, then | |||||
* change + save that (only). See bug #60010 | |||||
* TODO Fix this to work! | |||||
*/ | |||||
@Test | |||||
@Ignore | |||||
public void createFromReadOnlyWorkbook() throws Exception { | |||||
File input = XSSFTestDataSamples.getSampleFile("sample.xlsx"); | |||||
OPCPackage pkg = OPCPackage.open(input, PackageAccess.READ); | |||||
XSSFWorkbook xssf = new XSSFWorkbook(pkg); | |||||
SXSSFWorkbook wb = new SXSSFWorkbook(xssf, 2); | |||||
String sheetName = "Test SXSSF"; | |||||
Sheet s = wb.createSheet(sheetName); | |||||
for (int i=0; i<10; i++) { | |||||
Row r = s.createRow(i); | |||||
r.createCell(0).setCellValue(true); | |||||
r.createCell(1).setCellValue(2.4); | |||||
r.createCell(2).setCellValue("Test Row " + i); | |||||
} | |||||
assertEquals(10, s.getLastRowNum()); | |||||
ByteArrayOutputStream bos = new ByteArrayOutputStream(); | |||||
wb.write(bos); | |||||
wb.dispose(); | |||||
wb.close(); | |||||
xssf = new XSSFWorkbook(new ByteArrayInputStream(bos.toByteArray())); | |||||
s = xssf.getSheet(sheetName); | |||||
assertEquals(10, s.getLastRowNum()); | |||||
assertEquals(true, s.getRow(0).getCell(0).getBooleanCellValue()); | |||||
assertEquals("Test Row 9", s.getRow(9).getCell(2).getStringCellValue()); | |||||
} | |||||
} | } |
TestXSSFSheetComments.class, | TestXSSFSheetComments.class, | ||||
TestColumnHelper.class, | TestColumnHelper.class, | ||||
TestHeaderFooterHelper.class, | TestHeaderFooterHelper.class, | ||||
TestXSSFPivotTable.class, | |||||
//TestXSSFPivotTable.class, //converted to junit4 | |||||
TestForkedEvaluator.class | TestForkedEvaluator.class | ||||
}) | }) | ||||
public final class AllXSSFUsermodelTests { | public final class AllXSSFUsermodelTests { |
final CellType expectedCellType = expValue.getCellTypeEnum(); | final CellType expectedCellType = expValue.getCellTypeEnum(); | ||||
switch (expectedCellType) { | switch (expectedCellType) { | ||||
case BLANK: | case BLANK: | ||||
assertEquals(msg, CellType.BLANK, actValue.getCellType()); | |||||
assertEquals(msg, CellType.BLANK, actValue.getCellTypeEnum()); | |||||
break; | break; | ||||
case BOOLEAN: | case BOOLEAN: | ||||
assertEquals(msg, CellType.BOOLEAN, actValue.getCellType()); | |||||
assertEquals(msg, CellType.BOOLEAN, actValue.getCellTypeEnum()); | |||||
assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue()); | assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue()); | ||||
break; | break; | ||||
case ERROR: | case ERROR: | ||||
assertEquals(msg, CellType.ERROR, actValue.getCellType()); | |||||
assertEquals(msg, CellType.ERROR, actValue.getCellTypeEnum()); | |||||
// if(false) { // TODO: fix ~45 functions which are currently returning incorrect error values | // if(false) { // TODO: fix ~45 functions which are currently returning incorrect error values | ||||
// assertEquals(msg, expValue.getErrorCellValue(), actValue.getErrorValue()); | // assertEquals(msg, expValue.getErrorCellValue(), actValue.getErrorValue()); | ||||
// } | // } | ||||
case FORMULA: // will never be used, since we will call method after formula evaluation | case FORMULA: // will never be used, since we will call method after formula evaluation | ||||
fail("Cannot expect formula as result of formula evaluation: " + msg); | fail("Cannot expect formula as result of formula evaluation: " + msg); | ||||
case NUMERIC: | case NUMERIC: | ||||
assertEquals(msg, CellType.NUMERIC, actValue.getCellType()); | |||||
assertEquals(msg, CellType.NUMERIC, actValue.getCellTypeEnum()); | |||||
TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR); | TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR); | ||||
// double delta = Math.abs(expValue.getNumericCellValue()-actValue.getNumberValue()); | // double delta = Math.abs(expValue.getNumericCellValue()-actValue.getNumberValue()); | ||||
// double pctExpValue = Math.abs(0.00001*expValue.getNumericCellValue()); | // double pctExpValue = Math.abs(0.00001*expValue.getNumericCellValue()); | ||||
// assertTrue(msg, delta <= pctExpValue); | // assertTrue(msg, delta <= pctExpValue); | ||||
break; | break; | ||||
case STRING: | case STRING: | ||||
assertEquals(msg, CellType.STRING, actValue.getCellType()); | |||||
assertEquals(msg, CellType.STRING, actValue.getCellTypeEnum()); | |||||
assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue()); | assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue()); | ||||
break; | break; | ||||
default: | default: |
final CellType expectedCellType = expValue.getCellTypeEnum(); | final CellType expectedCellType = expValue.getCellTypeEnum(); | ||||
switch (expectedCellType) { | switch (expectedCellType) { | ||||
case BLANK: | case BLANK: | ||||
assertEquals(msg, CellType.BLANK, actValue.getCellType()); | |||||
assertEquals(msg, CellType.BLANK, actValue.getCellTypeEnum()); | |||||
break; | break; | ||||
case BOOLEAN: | case BOOLEAN: | ||||
assertEquals(msg, CellType.BOOLEAN, actValue.getCellType()); | |||||
assertEquals(msg, CellType.BOOLEAN, actValue.getCellTypeEnum()); | |||||
assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue()); | assertEquals(msg, expValue.getBooleanCellValue(), actValue.getBooleanValue()); | ||||
break; | break; | ||||
case ERROR: | case ERROR: | ||||
assertEquals(msg, CellType.ERROR, actValue.getCellType()); | |||||
assertEquals(msg, CellType.ERROR, actValue.getCellTypeEnum()); | |||||
// if(false) { // TODO: fix ~45 functions which are currently returning incorrect error values | // if(false) { // TODO: fix ~45 functions which are currently returning incorrect error values | ||||
// assertEquals(msg, expected.getErrorCellValue(), actual.getErrorValue()); | // assertEquals(msg, expected.getErrorCellValue(), actual.getErrorValue()); | ||||
// } | // } | ||||
case FORMULA: // will never be used, since we will call method after formula evaluation | case FORMULA: // will never be used, since we will call method after formula evaluation | ||||
fail("Cannot expect formula as result of formula evaluation: " + msg); | fail("Cannot expect formula as result of formula evaluation: " + msg); | ||||
case NUMERIC: | case NUMERIC: | ||||
assertEquals(msg, CellType.NUMERIC, actValue.getCellType()); | |||||
assertEquals(msg, CellType.NUMERIC, actValue.getCellTypeEnum()); | |||||
TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR); | TestMathX.assertEquals(msg, expValue.getNumericCellValue(), actValue.getNumberValue(), TestMathX.POS_ZERO, TestMathX.DIFF_TOLERANCE_FACTOR); | ||||
// double delta = Math.abs(expected.getNumericCellValue()-actual.getNumberValue()); | // double delta = Math.abs(expected.getNumericCellValue()-actual.getNumberValue()); | ||||
// double pctExpected = Math.abs(0.00001*expected.getNumericCellValue()); | // double pctExpected = Math.abs(0.00001*expected.getNumericCellValue()); | ||||
// assertTrue(msg, delta <= pctExpected); | // assertTrue(msg, delta <= pctExpected); | ||||
break; | break; | ||||
case STRING: | case STRING: | ||||
assertEquals(msg, CellType.STRING, actValue.getCellType()); | |||||
assertEquals(msg, CellType.STRING, actValue.getCellTypeEnum()); | |||||
assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue()); | assertEquals(msg, expValue.getRichStringCellValue().getString(), actValue.getStringValue()); | ||||
break; | break; | ||||
default: | default: |
if(c.getCellTypeEnum() == CellType.FORMULA) { | if(c.getCellTypeEnum() == CellType.FORMULA) { | ||||
CellValue cv = eval.evaluate(c); | CellValue cv = eval.evaluate(c); | ||||
if(cv.getCellType() == CellType.NUMERIC) { | |||||
if(cv.getCellTypeEnum() == CellType.NUMERIC) { | |||||
// assert that the calculated value agrees with | // assert that the calculated value agrees with | ||||
// the cached formula result calculated by Excel | // the cached formula result calculated by Excel | ||||
String formula = c.getCellFormula(); | String formula = c.getCellFormula(); | ||||
assertEquals("E4+E5", cell.getCellFormula()); | assertEquals("E4+E5", cell.getCellFormula()); | ||||
CellValue value = evaluator.evaluate(cell); | CellValue value = evaluator.evaluate(cell); | ||||
assertEquals(CellType.ERROR, value.getCellType()); | |||||
assertEquals(CellType.ERROR, value.getCellTypeEnum()); | |||||
assertEquals(-60, value.getErrorValue()); | assertEquals(-60, value.getErrorValue()); | ||||
assertEquals("~CIRCULAR~REF~", FormulaError.forInt(value.getErrorValue()).getString()); | assertEquals("~CIRCULAR~REF~", FormulaError.forInt(value.getErrorValue()).getString()); | ||||
assertEquals("CIRCULAR_REF", FormulaError.forInt(value.getErrorValue()).toString()); | assertEquals("CIRCULAR_REF", FormulaError.forInt(value.getErrorValue()).toString()); |
@Test | @Test | ||||
public void testGetSetBorderBottom() { | public void testGetSetBorderBottom() { | ||||
//default values | //default values | ||||
assertEquals(BorderStyle.NONE, cellStyle.getBorderBottom()); | |||||
assertEquals(BorderStyle.NONE, cellStyle.getBorderBottomEnum()); | |||||
int num = stylesTable.getBorders().size(); | int num = stylesTable.getBorders().size(); | ||||
cellStyle.setBorderBottom(BorderStyle.MEDIUM); | cellStyle.setBorderBottom(BorderStyle.MEDIUM); | ||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderBottom()); | |||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderBottomEnum()); | |||||
//a new border has been added | //a new border has been added | ||||
assertEquals(num + 1, stylesTable.getBorders().size()); | assertEquals(num + 1, stylesTable.getBorders().size()); | ||||
//id of the created border | //id of the created border | ||||
//setting the same border multiple times should not change borderId | //setting the same border multiple times should not change borderId | ||||
for (int i = 0; i < 3; i++) { | for (int i = 0; i < 3; i++) { | ||||
cellStyle.setBorderBottom(BorderStyle.MEDIUM); | cellStyle.setBorderBottom(BorderStyle.MEDIUM); | ||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderBottom()); | |||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderBottomEnum()); | |||||
} | } | ||||
assertEquals(borderId, cellStyle.getCoreXf().getBorderId()); | assertEquals(borderId, cellStyle.getCoreXf().getBorderId()); | ||||
assertEquals(num, stylesTable.getBorders().size()); | assertEquals(num, stylesTable.getBorders().size()); | ||||
@Test | @Test | ||||
public void testGetSetBorderRight() { | public void testGetSetBorderRight() { | ||||
//default values | //default values | ||||
assertEquals(BorderStyle.NONE, cellStyle.getBorderRight()); | |||||
assertEquals(BorderStyle.NONE, cellStyle.getBorderRightEnum()); | |||||
int num = stylesTable.getBorders().size(); | int num = stylesTable.getBorders().size(); | ||||
cellStyle.setBorderRight(BorderStyle.MEDIUM); | cellStyle.setBorderRight(BorderStyle.MEDIUM); | ||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderRight()); | |||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderRightEnum()); | |||||
//a new border has been added | //a new border has been added | ||||
assertEquals(num + 1, stylesTable.getBorders().size()); | assertEquals(num + 1, stylesTable.getBorders().size()); | ||||
//id of the created border | //id of the created border | ||||
//setting the same border multiple times should not change borderId | //setting the same border multiple times should not change borderId | ||||
for (int i = 0; i < 3; i++) { | for (int i = 0; i < 3; i++) { | ||||
cellStyle.setBorderRight(BorderStyle.MEDIUM); | cellStyle.setBorderRight(BorderStyle.MEDIUM); | ||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderRight()); | |||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderRightEnum()); | |||||
} | } | ||||
assertEquals(borderId, cellStyle.getCoreXf().getBorderId()); | assertEquals(borderId, cellStyle.getCoreXf().getBorderId()); | ||||
assertEquals(num, stylesTable.getBorders().size()); | assertEquals(num, stylesTable.getBorders().size()); | ||||
@Test | @Test | ||||
public void testGetSetBorderLeft() { | public void testGetSetBorderLeft() { | ||||
//default values | //default values | ||||
assertEquals(BorderStyle.NONE, cellStyle.getBorderLeft()); | |||||
assertEquals(BorderStyle.NONE, cellStyle.getBorderLeftEnum()); | |||||
int num = stylesTable.getBorders().size(); | int num = stylesTable.getBorders().size(); | ||||
cellStyle.setBorderLeft(BorderStyle.MEDIUM); | cellStyle.setBorderLeft(BorderStyle.MEDIUM); | ||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderLeft()); | |||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderLeftEnum()); | |||||
//a new border has been added | //a new border has been added | ||||
assertEquals(num + 1, stylesTable.getBorders().size()); | assertEquals(num + 1, stylesTable.getBorders().size()); | ||||
//id of the created border | //id of the created border | ||||
//setting the same border multiple times should not change borderId | //setting the same border multiple times should not change borderId | ||||
for (int i = 0; i < 3; i++) { | for (int i = 0; i < 3; i++) { | ||||
cellStyle.setBorderLeft(BorderStyle.MEDIUM); | cellStyle.setBorderLeft(BorderStyle.MEDIUM); | ||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderLeft()); | |||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderLeftEnum()); | |||||
} | } | ||||
assertEquals(borderId, cellStyle.getCoreXf().getBorderId()); | assertEquals(borderId, cellStyle.getCoreXf().getBorderId()); | ||||
assertEquals(num, stylesTable.getBorders().size()); | assertEquals(num, stylesTable.getBorders().size()); | ||||
@Test | @Test | ||||
public void testGetSetBorderTop() { | public void testGetSetBorderTop() { | ||||
//default values | //default values | ||||
assertEquals(BorderStyle.NONE, cellStyle.getBorderTop()); | |||||
assertEquals(BorderStyle.NONE, cellStyle.getBorderTopEnum()); | |||||
int num = stylesTable.getBorders().size(); | int num = stylesTable.getBorders().size(); | ||||
cellStyle.setBorderTop(BorderStyle.MEDIUM); | cellStyle.setBorderTop(BorderStyle.MEDIUM); | ||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderTop()); | |||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderTopEnum()); | |||||
//a new border has been added | //a new border has been added | ||||
assertEquals(num + 1, stylesTable.getBorders().size()); | assertEquals(num + 1, stylesTable.getBorders().size()); | ||||
//id of the created border | //id of the created border | ||||
//setting the same border multiple times should not change borderId | //setting the same border multiple times should not change borderId | ||||
for (int i = 0; i < 3; i++) { | for (int i = 0; i < 3; i++) { | ||||
cellStyle.setBorderTop(BorderStyle.MEDIUM); | cellStyle.setBorderTop(BorderStyle.MEDIUM); | ||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderTop()); | |||||
assertEquals(BorderStyle.MEDIUM, cellStyle.getBorderTopEnum()); | |||||
} | } | ||||
assertEquals(borderId, cellStyle.getCoreXf().getBorderId()); | assertEquals(borderId, cellStyle.getCoreXf().getBorderId()); | ||||
assertEquals(num, stylesTable.getBorders().size()); | assertEquals(num, stylesTable.getBorders().size()); | ||||
private void testGetSetBorderXMLBean(BorderStyle border, STBorderStyle.Enum expected) { | private void testGetSetBorderXMLBean(BorderStyle border, STBorderStyle.Enum expected) { | ||||
cellStyle.setBorderTop(border); | cellStyle.setBorderTop(border); | ||||
assertEquals(border, cellStyle.getBorderTop()); | |||||
assertEquals(border, cellStyle.getBorderTopEnum()); | |||||
int borderId = (int)cellStyle.getCoreXf().getBorderId(); | int borderId = (int)cellStyle.getCoreXf().getBorderId(); | ||||
assertTrue(borderId > 0); | assertTrue(borderId > 0); | ||||
//check changes in the underlying xml bean | //check changes in the underlying xml bean | ||||
@Test | @Test | ||||
public void testGetSetBorderNone() { | public void testGetSetBorderNone() { | ||||
cellStyle.setBorderTop(BorderStyle.NONE); | cellStyle.setBorderTop(BorderStyle.NONE); | ||||
assertEquals(BorderStyle.NONE, cellStyle.getBorderTop()); | |||||
assertEquals(BorderStyle.NONE, cellStyle.getBorderTopEnum()); | |||||
int borderId = (int)cellStyle.getCoreXf().getBorderId(); | int borderId = (int)cellStyle.getCoreXf().getBorderId(); | ||||
assertTrue(borderId > 0); | assertTrue(borderId > 0); | ||||
//check changes in the underlying xml bean | //check changes in the underlying xml bean | ||||
assertEquals(style2.getRightBorderColor(), style1.getRightBorderColor()); | assertEquals(style2.getRightBorderColor(), style1.getRightBorderColor()); | ||||
assertEquals(style2.getBottomBorderColor(), style1.getBottomBorderColor()); | assertEquals(style2.getBottomBorderColor(), style1.getBottomBorderColor()); | ||||
assertEquals(style2.getBorderBottom(), style1.getBorderBottom()); | |||||
assertEquals(style2.getBorderLeft(), style1.getBorderLeft()); | |||||
assertEquals(style2.getBorderRight(), style1.getBorderRight()); | |||||
assertEquals(style2.getBorderTop(), style1.getBorderTop()); | |||||
assertEquals(style2.getBorderBottomEnum(), style1.getBorderBottomEnum()); | |||||
assertEquals(style2.getBorderLeftEnum(), style1.getBorderLeftEnum()); | |||||
assertEquals(style2.getBorderRightEnum(), style1.getBorderRightEnum()); | |||||
assertEquals(style2.getBorderTopEnum(), style1.getBorderTopEnum()); | |||||
wb2.close(); | wb2.close(); | ||||
} | } | ||||
Workbook copy = XSSFTestDataSamples.writeOutAndReadBack(target); | Workbook copy = XSSFTestDataSamples.writeOutAndReadBack(target); | ||||
// previously this failed because the border-element was not copied over | // previously this failed because the border-element was not copied over | ||||
copy.getCellStyleAt((short)1).getBorderBottom(); | |||||
copy.getCellStyleAt((short)1).getBorderBottomEnum(); | |||||
copy.close(); | copy.close(); | ||||
value = evaluator.evaluate(cell); | value = evaluator.evaluate(cell); | ||||
assertEquals(1, value.getNumberValue(), 0.001); | assertEquals(1, value.getNumberValue(), 0.001); | ||||
} | } | ||||
@Test | |||||
public void evaluateInCellReturnsSameDataType() throws IOException { | |||||
XSSFWorkbook wb = new XSSFWorkbook(); | |||||
wb.createSheet().createRow(0).createCell(0); | |||||
XSSFFormulaEvaluator evaluator = wb.getCreationHelper().createFormulaEvaluator(); | |||||
XSSFCell cell = wb.getSheetAt(0).getRow(0).getCell(0); | |||||
XSSFCell same = evaluator.evaluateInCell(cell); | |||||
assertSame(cell, same); | |||||
wb.close(); | |||||
} | |||||
} | } |
==================================================================== */ | ==================================================================== */ | ||||
package org.apache.poi.xssf.usermodel; | package org.apache.poi.xssf.usermodel; | ||||
import static org.junit.Assert.assertEquals; | |||||
import static org.junit.Assert.assertNotNull; | |||||
import static org.junit.Assert.fail; | |||||
import java.io.IOException; | |||||
import org.apache.poi.ss.usermodel.Cell; | import org.apache.poi.ss.usermodel.Cell; | ||||
import org.apache.poi.ss.usermodel.CellType; | import org.apache.poi.ss.usermodel.CellType; | ||||
import org.apache.poi.ss.usermodel.DataConsolidateFunction; | import org.apache.poi.ss.usermodel.DataConsolidateFunction; | ||||
import org.apache.poi.ss.usermodel.Row; | import org.apache.poi.ss.usermodel.Row; | ||||
import org.apache.poi.ss.usermodel.Workbook; | |||||
import org.apache.poi.ss.util.AreaReference; | import org.apache.poi.ss.util.AreaReference; | ||||
import org.apache.poi.ss.util.CellReference; | import org.apache.poi.ss.util.CellReference; | ||||
import org.apache.poi.xssf.XSSFITestDataProvider; | |||||
import org.junit.After; | |||||
import org.junit.Before; | |||||
import org.junit.Test; | |||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageField; | import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageField; | ||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageFields; | import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPageFields; | ||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotFields; | import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotFields; | ||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableDefinition; | import org.openxmlformats.schemas.spreadsheetml.x2006.main.CTPivotTableDefinition; | ||||
import org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataConsolidateFunction; | import org.openxmlformats.schemas.spreadsheetml.x2006.main.STDataConsolidateFunction; | ||||
import junit.framework.TestCase; | |||||
public class TestXSSFPivotTable extends TestCase { | |||||
public class TestXSSFPivotTable { | |||||
private static final XSSFITestDataProvider _testDataProvider = XSSFITestDataProvider.instance; | |||||
private XSSFWorkbook wb; | |||||
private XSSFPivotTable pivotTable; | private XSSFPivotTable pivotTable; | ||||
private XSSFPivotTable offsetPivotTable; | private XSSFPivotTable offsetPivotTable; | ||||
private Cell offsetOuterCell; | private Cell offsetOuterCell; | ||||
@Override | |||||
@Before | |||||
public void setUp(){ | public void setUp(){ | ||||
Workbook wb = new XSSFWorkbook(); | |||||
XSSFSheet sheet = (XSSFSheet) wb.createSheet(); | |||||
wb = new XSSFWorkbook(); | |||||
XSSFSheet sheet = wb.createSheet(); | |||||
Row row1 = sheet.createRow(0); | Row row1 = sheet.createRow(0); | ||||
// Create a cell and put a value in it. | // Create a cell and put a value in it. | ||||
Cell cell12 = row1.createCell(3); | Cell cell12 = row1.createCell(3); | ||||
cell12.setCellValue(12.12); | cell12.setCellValue(12.12); | ||||
AreaReference source = new AreaReference("A1:C2"); | |||||
AreaReference source = new AreaReference("A1:C2", _testDataProvider.getSpreadsheetVersion()); | |||||
pivotTable = sheet.createPivotTable(source, new CellReference("H5")); | pivotTable = sheet.createPivotTable(source, new CellReference("H5")); | ||||
XSSFSheet offsetSheet = (XSSFSheet) wb.createSheet(); | |||||
XSSFSheet offsetSheet = wb.createSheet(); | |||||
Row tableRow_1 = offsetSheet.createRow(1); | Row tableRow_1 = offsetSheet.createRow(1); | ||||
offsetOuterCell = tableRow_1.createCell(1); | offsetOuterCell = tableRow_1.createCell(1); | ||||
AreaReference offsetSource = new AreaReference(new CellReference("C2"), new CellReference("E4")); | AreaReference offsetSource = new AreaReference(new CellReference("C2"), new CellReference("E4")); | ||||
offsetPivotTable = offsetSheet.createPivotTable(offsetSource, new CellReference("C6")); | offsetPivotTable = offsetSheet.createPivotTable(offsetSource, new CellReference("C6")); | ||||
} | } | ||||
@After | |||||
public void tearDown() throws IOException { | |||||
XSSFWorkbook wb2 = _testDataProvider.writeOutAndReadBack(wb); | |||||
wb.close(); | |||||
wb2.close(); | |||||
} | |||||
/** | /** | ||||
* Verify that when creating a row label it's created on the correct row | * Verify that when creating a row label it's created on the correct row | ||||
* and the count is increased by one. | * and the count is increased by one. | ||||
*/ | */ | ||||
@Test | |||||
public void testAddRowLabelToPivotTable() { | public void testAddRowLabelToPivotTable() { | ||||
int columnIndex = 0; | int columnIndex = 0; | ||||
/** | /** | ||||
* Verify that it's not possible to create a row label outside of the referenced area. | * Verify that it's not possible to create a row label outside of the referenced area. | ||||
*/ | */ | ||||
@Test | |||||
public void testAddRowLabelOutOfRangeThrowsException() { | public void testAddRowLabelOutOfRangeThrowsException() { | ||||
int columnIndex = 5; | int columnIndex = 5; | ||||
/** | /** | ||||
* Verify that when creating one column label, no col fields are being created. | * Verify that when creating one column label, no col fields are being created. | ||||
*/ | */ | ||||
@Test | |||||
public void testAddOneColumnLabelToPivotTableDoesNotCreateColField() { | public void testAddOneColumnLabelToPivotTableDoesNotCreateColField() { | ||||
int columnIndex = 0; | int columnIndex = 0; | ||||
/** | /** | ||||
* Verify that it's possible to create three column labels with different DataConsolidateFunction | * Verify that it's possible to create three column labels with different DataConsolidateFunction | ||||
*/ | */ | ||||
@Test | |||||
public void testAddThreeDifferentColumnLabelsToPivotTable() { | public void testAddThreeDifferentColumnLabelsToPivotTable() { | ||||
int columnOne = 0; | int columnOne = 0; | ||||
int columnTwo = 1; | int columnTwo = 1; | ||||
/** | /** | ||||
* Verify that it's possible to create three column labels with the same DataConsolidateFunction | * Verify that it's possible to create three column labels with the same DataConsolidateFunction | ||||
*/ | */ | ||||
@Test | |||||
public void testAddThreeSametColumnLabelsToPivotTable() { | public void testAddThreeSametColumnLabelsToPivotTable() { | ||||
int columnOne = 0; | int columnOne = 0; | ||||
int columnTwo = 1; | int columnTwo = 1; | ||||
/** | /** | ||||
* Verify that when creating two column labels, a col field is being created and X is set to -2. | * Verify that when creating two column labels, a col field is being created and X is set to -2. | ||||
*/ | */ | ||||
@Test | |||||
public void testAddTwoColumnLabelsToPivotTable() { | public void testAddTwoColumnLabelsToPivotTable() { | ||||
int columnOne = 0; | int columnOne = 0; | ||||
int columnTwo = 1; | int columnTwo = 1; | ||||
/** | /** | ||||
* Verify that a data field is created when creating a data column | * Verify that a data field is created when creating a data column | ||||
*/ | */ | ||||
@Test | |||||
public void testColumnLabelCreatesDataField() { | public void testColumnLabelCreatesDataField() { | ||||
int columnIndex = 0; | int columnIndex = 0; | ||||
/** | /** | ||||
* Verify that it's possible to set a custom name when creating a data column | * Verify that it's possible to set a custom name when creating a data column | ||||
*/ | */ | ||||
@Test | |||||
public void testColumnLabelSetCustomName() { | public void testColumnLabelSetCustomName() { | ||||
int columnIndex = 0; | int columnIndex = 0; | ||||
/** | /** | ||||
* Verify that it's not possible to create a column label outside of the referenced area. | * Verify that it's not possible to create a column label outside of the referenced area. | ||||
*/ | */ | ||||
@Test | |||||
public void testAddColumnLabelOutOfRangeThrowsException() { | public void testAddColumnLabelOutOfRangeThrowsException() { | ||||
int columnIndex = 5; | int columnIndex = 5; | ||||
* Verify when creating a data column set to a data field, the data field with the corresponding | * Verify when creating a data column set to a data field, the data field with the corresponding | ||||
* column index will be set to true. | * column index will be set to true. | ||||
*/ | */ | ||||
@Test | |||||
public void testAddDataColumn() { | public void testAddDataColumn() { | ||||
int columnIndex = 0; | int columnIndex = 0; | ||||
boolean isDataField = true; | boolean isDataField = true; | ||||
/** | /** | ||||
* Verify that it's not possible to create a data column outside of the referenced area. | * Verify that it's not possible to create a data column outside of the referenced area. | ||||
*/ | */ | ||||
@Test | |||||
public void testAddDataColumnOutOfRangeThrowsException() { | public void testAddDataColumnOutOfRangeThrowsException() { | ||||
int columnIndex = 5; | int columnIndex = 5; | ||||
boolean isDataField = true; | boolean isDataField = true; | ||||
/** | /** | ||||
* Verify that it's not possible to create a new filter outside of the referenced area. | * Verify that it's not possible to create a new filter outside of the referenced area. | ||||
*/ | */ | ||||
@Test | |||||
public void testAddReportFilterOutOfRangeThrowsException() { | public void testAddReportFilterOutOfRangeThrowsException() { | ||||
int columnIndex = 5; | int columnIndex = 5; | ||||
try { | try { | ||||
* Verify that the Pivot Table operates only within the referenced area, even when the | * Verify that the Pivot Table operates only within the referenced area, even when the | ||||
* first column of the referenced area is not index 0. | * first column of the referenced area is not index 0. | ||||
*/ | */ | ||||
@Test | |||||
public void testAddDataColumnWithOffsetData() { | public void testAddDataColumnWithOffsetData() { | ||||
offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1); | offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 1); | ||||
assertEquals(CellType.NUMERIC, offsetOuterCell.getCellTypeEnum()); | assertEquals(CellType.NUMERIC, offsetOuterCell.getCellTypeEnum()); | ||||
offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 0); | offsetPivotTable.addColumnLabel(DataConsolidateFunction.SUM, 0); | ||||
} | } | ||||
@Test | |||||
public void testPivotTableSheetNamesAreCaseInsensitive() { | |||||
wb.setSheetName(0, "original"); | |||||
wb.setSheetName(1, "offset"); | |||||
XSSFSheet original = wb.getSheet("OriginaL"); | |||||
XSSFSheet offset = wb.getSheet("OffseT"); | |||||
// assume sheets are accessible via case-insensitive name | |||||
assertNotNull(original); | |||||
assertNotNull(offset); | |||||
AreaReference source = new AreaReference("ORIGinal!A1:C2", _testDataProvider.getSpreadsheetVersion()); | |||||
// create a pivot table on the same sheet, case insensitive | |||||
original.createPivotTable(source, new CellReference("W1")); | |||||
// create a pivot table on a different sheet, case insensitive | |||||
offset.createPivotTable(source, new CellReference("W1")); | |||||
} | |||||
} | } |
import org.apache.poi.ss.usermodel.CellCopyPolicy; | import org.apache.poi.ss.usermodel.CellCopyPolicy; | ||||
import org.apache.poi.ss.usermodel.CellType; | import org.apache.poi.ss.usermodel.CellType; | ||||
import org.apache.poi.ss.usermodel.ClientAnchor; | import org.apache.poi.ss.usermodel.ClientAnchor; | ||||
import org.apache.poi.ss.usermodel.Comment; | |||||
import org.apache.poi.ss.usermodel.CreationHelper; | |||||
import org.apache.poi.ss.usermodel.Drawing; | |||||
import org.apache.poi.ss.usermodel.FormulaError; | import org.apache.poi.ss.usermodel.FormulaError; | ||||
import org.apache.poi.ss.usermodel.IgnoredErrorType; | import org.apache.poi.ss.usermodel.IgnoredErrorType; | ||||
import org.apache.poi.ss.usermodel.IndexedColors; | import org.apache.poi.ss.usermodel.IndexedColors; | ||||
wb.close(); | wb.close(); | ||||
} | } | ||||
} | } | ||||
/** | |||||
* See bug #52425 | |||||
*/ | |||||
@Test | |||||
public void testInsertCommentsToClonedSheet() { | |||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("52425.xlsx"); | |||||
CreationHelper helper = wb.getCreationHelper(); | |||||
Sheet sheet2 = wb.createSheet("Sheet 2"); | |||||
Sheet sheet3 = wb.cloneSheet(0); | |||||
wb.setSheetName(2, "Sheet 3"); | |||||
// Adding Comment to new created Sheet 2 | |||||
addComments(helper, sheet2); | |||||
// Adding Comment to cloned Sheet 3 | |||||
addComments(helper, sheet3); | |||||
} | |||||
private void addComments(CreationHelper helper, Sheet sheet) { | |||||
Drawing drawing = sheet.createDrawingPatriarch(); | |||||
for (int i = 0; i < 2; i++) { | |||||
ClientAnchor anchor = helper.createClientAnchor(); | |||||
anchor.setCol1(0); | |||||
anchor.setRow1(0 + i); | |||||
anchor.setCol2(2); | |||||
anchor.setRow2(3 + i); | |||||
Comment comment = drawing.createCellComment(anchor); | |||||
comment.setString(helper.createRichTextString("BugTesting")); | |||||
Row row = sheet.getRow(0 + i); | |||||
if (row == null) | |||||
row = sheet.createRow(0 + i); | |||||
Cell cell = row.getCell(0); | |||||
if (cell == null) | |||||
cell = row.createCell(0); | |||||
cell.setCellComment(comment); | |||||
} | |||||
} | |||||
} | } |
// TODO - support shifting of page breaks | // TODO - support shifting of page breaks | ||||
} | } | ||||
/** Error occurred at FormulaShifter#rowMoveAreaPtg while shift rows upward. */ | |||||
@Test | @Test | ||||
public void testBug54524() throws IOException { | public void testBug54524() throws IOException { | ||||
XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("54524.xlsx"); | XSSFWorkbook workbook = XSSFTestDataSamples.openSampleWorkbook("54524.xlsx"); | ||||
workbook.close(); | workbook.close(); | ||||
} | } | ||||
/** negative row shift causes corrupted data or throws exception */ | |||||
@Test | @Test | ||||
public void testBug53798() throws IOException { | public void testBug53798() throws IOException { | ||||
// NOTE that for HSSF (.xls) negative shifts combined with positive ones do work as expected | // NOTE that for HSSF (.xls) negative shifts combined with positive ones do work as expected | ||||
} | } | ||||
} | } | ||||
/** negative row shift causes corrupted data or throws exception */ | |||||
@Test | @Test | ||||
public void testBug53798a() throws IOException { | public void testBug53798a() throws IOException { | ||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53798.xlsx"); | Workbook wb = XSSFTestDataSamples.openSampleWorkbook("53798.xlsx"); | ||||
read.close(); | read.close(); | ||||
} | } | ||||
/** Shifting rows with comment result - Unreadable content error and comment deletion */ | |||||
@Test | @Test | ||||
public void testBug56017() throws IOException { | public void testBug56017() throws IOException { | ||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56017.xlsx"); | Workbook wb = XSSFTestDataSamples.openSampleWorkbook("56017.xlsx"); | ||||
wbBack.close(); | wbBack.close(); | ||||
} | } | ||||
/** Moving the active sheet and deleting the others results in a corrupted file */ | |||||
@Test | @Test | ||||
public void test57171() throws IOException { | public void test57171() throws IOException { | ||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx"); | Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx"); | ||||
wbRead.close(); | wbRead.close(); | ||||
} | } | ||||
/** Cannot delete an arbitrary sheet in an XLS workbook (only the last one) */ | |||||
@Test | @Test | ||||
public void test57163() throws IOException { | public void test57163() throws IOException { | ||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx"); | Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx"); | ||||
wb.close(); | wb.close(); | ||||
} | } | ||||
/** Failed to clone a sheet from an Excel 2010 */ | |||||
@Test | @Test | ||||
public void test57165() throws IOException { | public void test57165() throws IOException { | ||||
Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx"); | Workbook wb = XSSFTestDataSamples.openSampleWorkbook("57171_57163_57165.xlsx"); | ||||
} | } | ||||
} | } | ||||
/** Shifting rows with cell comments only shifts comments from first such cell. Other cell comments not shifted */ | |||||
@Test | @Test | ||||
public void testBug57828_OnlyOneCommentShiftedInRow() throws IOException { | public void testBug57828_OnlyOneCommentShiftedInRow() throws IOException { | ||||
XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57828.xlsx"); | XSSFWorkbook wb = XSSFTestDataSamples.openSampleWorkbook("57828.xlsx"); |
* @param format The format of the picture. | * @param format The format of the picture. | ||||
* | * | ||||
* @return the picture data. | * @return the picture data. | ||||
* @since 3.15 beta 2 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public HSLFPictureData addPicture(InputStream is, PictureType format) throws IOException { | public HSLFPictureData addPicture(InputStream is, PictureType format) throws IOException { | ||||
* The format of the picture. | * The format of the picture. | ||||
* | * | ||||
* @return the picture data. | * @return the picture data. | ||||
* @since 3.15 beta 2 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public HSLFPictureData addPicture(File pict, PictureType format) throws IOException { | public HSLFPictureData addPicture(File pict, PictureType format) throws IOException { | ||||
* | * | ||||
* @param pictureData The picture data to find in the SlideShow | * @param pictureData The picture data to find in the SlideShow | ||||
* @return {@code null} if picture data is not found in this slideshow | * @return {@code null} if picture data is not found in this slideshow | ||||
* @since 3.15 beta 3 | |||||
*/ | */ | ||||
@Override | @Override | ||||
public HSLFPictureData findPictureData(byte[] pictureData) { | public HSLFPictureData findPictureData(byte[] pictureData) { |
protected boolean isEmptyStyle( CellStyle cellStyle ) { | protected boolean isEmptyStyle( CellStyle cellStyle ) { | ||||
return cellStyle == null || ( | return cellStyle == null || ( | ||||
cellStyle.getFillPattern() == 0 | cellStyle.getFillPattern() == 0 | ||||
&& cellStyle.getBorderTop() == BorderStyle.NONE | |||||
&& cellStyle.getBorderRight() == BorderStyle.NONE | |||||
&& cellStyle.getBorderBottom() == BorderStyle.NONE | |||||
&& cellStyle.getBorderLeft() == BorderStyle.NONE | |||||
&& cellStyle.getBorderTopEnum() == BorderStyle.NONE | |||||
&& cellStyle.getBorderRightEnum() == BorderStyle.NONE | |||||
&& cellStyle.getBorderBottomEnum() == BorderStyle.NONE | |||||
&& cellStyle.getBorderLeftEnum() == BorderStyle.NONE | |||||
); | ); | ||||
} | } | ||||
} | } | ||||
processCellStyleBorder( workbook, cellTarget, "top", | processCellStyleBorder( workbook, cellTarget, "top", | ||||
cellStyle.getBorderTop(), cellStyle.getTopBorderColor() ); | |||||
cellStyle.getBorderTopEnum(), cellStyle.getTopBorderColor() ); | |||||
processCellStyleBorder( workbook, cellTarget, "right", | processCellStyleBorder( workbook, cellTarget, "right", | ||||
cellStyle.getBorderRight(), cellStyle.getRightBorderColor() ); | |||||
cellStyle.getBorderRightEnum(), cellStyle.getRightBorderColor() ); | |||||
processCellStyleBorder( workbook, cellTarget, "bottom", | processCellStyleBorder( workbook, cellTarget, "bottom", | ||||
cellStyle.getBorderBottom(), cellStyle.getBottomBorderColor() ); | |||||
cellStyle.getBorderBottomEnum(), cellStyle.getBottomBorderColor() ); | |||||
processCellStyleBorder( workbook, cellTarget, "left", | processCellStyleBorder( workbook, cellTarget, "left", | ||||
cellStyle.getBorderLeft(), cellStyle.getLeftBorderColor() ); | |||||
cellStyle.getBorderLeftEnum(), cellStyle.getLeftBorderColor() ); | |||||
HSSFFont font = cellStyle.getFont( workbook ); | HSSFFont font = cellStyle.getFont( workbook ); | ||||
processCellStyleFont( workbook, blockTarget, font ); | processCellStyleFont( workbook, blockTarget, font ); |
break; | break; | ||||
} | } | ||||
buildStyle_border( workbook, style, "top", cellStyle.getBorderTop(), | |||||
buildStyle_border( workbook, style, "top", cellStyle.getBorderTopEnum(), | |||||
cellStyle.getTopBorderColor() ); | cellStyle.getTopBorderColor() ); | ||||
buildStyle_border( workbook, style, "right", | buildStyle_border( workbook, style, "right", | ||||
cellStyle.getBorderRight(), cellStyle.getRightBorderColor() ); | |||||
cellStyle.getBorderRightEnum(), cellStyle.getRightBorderColor() ); | |||||
buildStyle_border( workbook, style, "bottom", | buildStyle_border( workbook, style, "bottom", | ||||
cellStyle.getBorderBottom(), cellStyle.getBottomBorderColor() ); | |||||
buildStyle_border( workbook, style, "left", cellStyle.getBorderLeft(), | |||||
cellStyle.getBorderBottomEnum(), cellStyle.getBottomBorderColor() ); | |||||
buildStyle_border( workbook, style, "left", cellStyle.getBorderLeftEnum(), | |||||
cellStyle.getLeftBorderColor() ); | cellStyle.getLeftBorderColor() ); | ||||
HSSFFont font = cellStyle.getFont( workbook ); | HSSFFont font = cellStyle.getFont( workbook ); |
import static org.junit.Assert.assertTrue; | import static org.junit.Assert.assertTrue; | ||||
import java.io.ByteArrayInputStream; | import java.io.ByteArrayInputStream; | ||||
import java.io.IOException; | |||||
import java.io.InputStream; | import java.io.InputStream; | ||||
import java.io.OutputStream; | |||||
import java.io.PrintStream; | import java.io.PrintStream; | ||||
import java.io.UnsupportedEncodingException; | import java.io.UnsupportedEncodingException; | ||||
import org.apache.poi.hssf.HSSFTestDataSamples; | import org.apache.poi.hssf.HSSFTestDataSamples; | ||||
import org.apache.poi.util.IOUtils; | import org.apache.poi.util.IOUtils; | ||||
import org.apache.poi.util.LocaleUtil; | import org.apache.poi.util.LocaleUtil; | ||||
import org.apache.poi.util.NullOutputStream; | |||||
import org.junit.BeforeClass; | import org.junit.BeforeClass; | ||||
import org.junit.Test; | import org.junit.Test; | ||||
@SuppressWarnings("resource") | @SuppressWarnings("resource") | ||||
private NullPrinterStream() throws UnsupportedEncodingException { | private NullPrinterStream() throws UnsupportedEncodingException { | ||||
super(new NullOutputStream(),true,LocaleUtil.CHARSET_1252.name()); | super(new NullOutputStream(),true,LocaleUtil.CHARSET_1252.name()); | ||||
} | |||||
/** | |||||
* Implementation of an OutputStream which does nothing, used | |||||
* to redirect stdout to avoid spamming the console with output | |||||
*/ | |||||
private static class NullOutputStream extends OutputStream { | |||||
@Override | |||||
public void write(byte[] b, int off, int len) { | |||||
} | |||||
@Override | |||||
public void write(int b) { | |||||
} | |||||
@Override | |||||
public void write(byte[] b) throws IOException { | |||||
} | |||||
} | |||||
} | |||||
} | } | ||||
} | } |