mirror of https://github.com/apache/poi.git
Try to use https for poi.apache.org everywhere
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1874981 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a7d96dcb73
commit
77fbcb788d
|
@ -28,9 +28,9 @@
|
||||||
<version>@VERSION@</version>
|
<version>@VERSION@</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>OOXML schemas</name>
|
<name>OOXML schemas</name>
|
||||||
<description>XmlBeans generated from the Ecma supplied xsds:
|
<description>XmlBeans generated from the Ecma supplied xsds:
|
||||||
http://www.ecma-international.org/publications/files/ECMA-ST/Office%20Open%20XML%20Part%204%20(DOCX).zip</description>
|
http://www.ecma-international.org/publications/files/ECMA-ST/Office%20Open%20XML%20Part%204%20(DOCX).zip</description>
|
||||||
<url>http://poi.apache.org/</url>
|
<url>https://poi.apache.org/</url>
|
||||||
|
|
||||||
<mailingLists>
|
<mailingLists>
|
||||||
<mailingList>
|
<mailingList>
|
||||||
|
|
|
@ -31,7 +31,7 @@
|
||||||
<description>
|
<description>
|
||||||
XmlBeans generated from various supplied xsds for encryption and signing:
|
XmlBeans generated from various supplied xsds for encryption and signing:
|
||||||
http://msdn.microsoft.com/en-us/library/dd925810(v=office.12).aspx
|
http://msdn.microsoft.com/en-us/library/dd925810(v=office.12).aspx
|
||||||
http://www.ecma-international.org/publications/files/ECMA-ST/Office%20Open%20XML%201st%20edition%20Part%202%20(PDF).zip
|
http://www.ecma-international.org/publications/files/ECMA-ST/Office%20Open%20XML%201st%20edition%20Part%202%20(PDF).zip
|
||||||
http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd
|
http://www.w3.org/TR/2002/REC-xmldsig-core-20020212/xmldsig-core-schema.xsd
|
||||||
http://uri.etsi.org/01903/v1.3.2/XAdES.xsd
|
http://uri.etsi.org/01903/v1.3.2/XAdES.xsd
|
||||||
http://uri.etsi.org/01903/v1.4.1/XAdESv141.xsd
|
http://uri.etsi.org/01903/v1.4.1/XAdESv141.xsd
|
||||||
|
@ -39,7 +39,7 @@
|
||||||
http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcterms.xsd
|
http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcterms.xsd
|
||||||
http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcmitype.xsd
|
http://dublincore.org/schemas/xmls/qdc/2003/04/02/dcmitype.xsd
|
||||||
</description>
|
</description>
|
||||||
<url>http://poi.apache.org/</url>
|
<url>https://poi.apache.org/</url>
|
||||||
|
|
||||||
<mailingLists>
|
<mailingLists>
|
||||||
<mailingList>
|
<mailingList>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<version>@VERSION@</version>
|
<version>@VERSION@</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Apache POI</name>
|
<name>Apache POI</name>
|
||||||
<url>http://poi.apache.org/</url>
|
<url>https://poi.apache.org/</url>
|
||||||
<description>Apache POI Examples</description>
|
<description>Apache POI Examples</description>
|
||||||
|
|
||||||
<mailingLists>
|
<mailingLists>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<version>@VERSION@</version>
|
<version>@VERSION@</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Apache POI</name>
|
<name>Apache POI</name>
|
||||||
<url>http://poi.apache.org/</url>
|
<url>https://poi.apache.org/</url>
|
||||||
<description>Apache POI Excel Ant Tasks</description>
|
<description>Apache POI Excel Ant Tasks</description>
|
||||||
|
|
||||||
<mailingLists>
|
<mailingLists>
|
||||||
|
@ -73,6 +73,6 @@
|
||||||
<groupId>org.apache.ant</groupId>
|
<groupId>org.apache.ant</groupId>
|
||||||
<artifactId>ant</artifactId>
|
<artifactId>ant</artifactId>
|
||||||
<version>1.8.2</version>
|
<version>1.8.2</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<version>@VERSION@</version>
|
<version>@VERSION@</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Apache POI</name>
|
<name>Apache POI</name>
|
||||||
<url>http://poi.apache.org/</url>
|
<url>https://poi.apache.org/</url>
|
||||||
<description>Apache POI - Java API To Access Microsoft Format Files</description>
|
<description>Apache POI - Java API To Access Microsoft Format Files</description>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<version>@VERSION@</version>
|
<version>@VERSION@</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Apache POI</name>
|
<name>Apache POI</name>
|
||||||
<url>http://poi.apache.org/</url>
|
<url>https://poi.apache.org/</url>
|
||||||
<description>Apache POI - Java API To Access Microsoft Format Files</description>
|
<description>Apache POI - Java API To Access Microsoft Format Files</description>
|
||||||
|
|
||||||
<mailingLists>
|
<mailingLists>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<version>@VERSION@</version>
|
<version>@VERSION@</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Apache POI</name>
|
<name>Apache POI</name>
|
||||||
<url>http://poi.apache.org/</url>
|
<url>https://poi.apache.org/</url>
|
||||||
<description>Apache POI - Java API To Access Microsoft Format Files</description>
|
<description>Apache POI - Java API To Access Microsoft Format Files</description>
|
||||||
|
|
||||||
<mailingLists>
|
<mailingLists>
|
||||||
|
|
|
@ -28,7 +28,7 @@
|
||||||
<version>@VERSION@</version>
|
<version>@VERSION@</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
<name>Apache POI</name>
|
<name>Apache POI</name>
|
||||||
<url>http://poi.apache.org/</url>
|
<url>https://poi.apache.org/</url>
|
||||||
<description>Apache POI - Java API To Access Microsoft Format Files</description>
|
<description>Apache POI - Java API To Access Microsoft Format Files</description>
|
||||||
|
|
||||||
<mailingLists>
|
<mailingLists>
|
||||||
|
|
|
@ -35,4 +35,4 @@
|
||||||
When practical, we donate components directly to those projects for POI-enabling them.
|
When practical, we donate components directly to those projects for POI-enabling them.
|
||||||
|
|
||||||
\u001B[1mSEE ALSO\u001B[0m
|
\u001B[1mSEE ALSO\u001B[0m
|
||||||
\u001B[36mhttp://poi.apache.org/\u001B[0m
|
\u001B[36mhttps://poi.apache.org/\u001B[0m
|
||||||
|
|
|
@ -35,7 +35,7 @@
|
||||||
<description>
|
<description>
|
||||||
OSGi bundle that contains Apache POI, and the dependencies.
|
OSGi bundle that contains Apache POI, and the dependencies.
|
||||||
</description>
|
</description>
|
||||||
<url>http://poi.apache.org/</url>
|
<url>https://poi.apache.org/</url>
|
||||||
<version>${poi.version}</version>
|
<version>${poi.version}</version>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
<version>4.1.3-SNAPSHOT</version>
|
<version>4.1.3-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>https://poi.apache.org/</url>
|
||||||
|
|
||||||
<mailingLists>
|
<mailingLists>
|
||||||
<mailingList>
|
<mailingList>
|
||||||
|
|
|
@ -434,7 +434,7 @@ public final class ApacheconEU08 {
|
||||||
tp.get(i).getTextRuns().get(0).setFontSize(24d);
|
tp.get(i).getTextRuns().get(0).setFontSize(24d);
|
||||||
tp.get(i).setIndentLevel(1);
|
tp.get(i).setIndentLevel(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
box2.setAnchor(new Rectangle(36, 126, 648, 400));
|
box2.setAnchor(new Rectangle(36, 126, 648, 400));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -449,7 +449,7 @@ public final class ApacheconEU08 {
|
||||||
TextBox<?,?> box2 = slide.createTextBox();
|
TextBox<?,?> box2 = slide.createTextBox();
|
||||||
box2.setTextPlaceholder(TextPlaceholder.CENTER_BODY);
|
box2.setTextPlaceholder(TextPlaceholder.CENTER_BODY);
|
||||||
box2.setText(
|
box2.setText(
|
||||||
"http://poi.apache.org/hslf/\r" +
|
"https://poi.apache.org/hslf/\r" +
|
||||||
"http://people.apache.org/~yegor");
|
"http://people.apache.org/~yegor");
|
||||||
box2.setAnchor(new Rectangle(108, 306, 504, 138));
|
box2.setAnchor(new Rectangle(108, 306, 504, 138));
|
||||||
}
|
}
|
||||||
|
|
|
@ -55,7 +55,7 @@ public class Hyperlinks {
|
||||||
cell = sheet.createRow(0).createCell(0);
|
cell = sheet.createRow(0).createCell(0);
|
||||||
cell.setCellValue("URL Link");
|
cell.setCellValue("URL Link");
|
||||||
HSSFHyperlink link = helper.createHyperlink(HyperlinkType.URL);
|
HSSFHyperlink link = helper.createHyperlink(HyperlinkType.URL);
|
||||||
link.setAddress("http://poi.apache.org/");
|
link.setAddress("https://poi.apache.org/");
|
||||||
cell.setHyperlink(link);
|
cell.setHyperlink(link);
|
||||||
cell.setCellStyle(hlink_style);
|
cell.setCellStyle(hlink_style);
|
||||||
|
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
* See the License for the specific language governing permissions and
|
* See the License for the specific language governing permissions and
|
||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
* ====================================================================
|
* ====================================================================
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package org.apache.poi.xslf.usermodel;
|
package org.apache.poi.xslf.usermodel;
|
||||||
|
@ -37,8 +37,8 @@ public class Tutorial6 {
|
||||||
shape1.setAnchor(new Rectangle(50, 50, 200, 50));
|
shape1.setAnchor(new Rectangle(50, 50, 200, 50));
|
||||||
XSLFTextRun r1 = shape1.addNewTextParagraph().addNewTextRun();
|
XSLFTextRun r1 = shape1.addNewTextParagraph().addNewTextRun();
|
||||||
XSLFHyperlink link1 = r1.createHyperlink();
|
XSLFHyperlink link1 = r1.createHyperlink();
|
||||||
r1.setText("http://poi.apache.org"); // visible text
|
r1.setText("https://poi.apache.org"); // visible text
|
||||||
link1.setAddress("http://poi.apache.org"); // link address
|
link1.setAddress("https://poi.apache.org"); // link address
|
||||||
|
|
||||||
XSLFTextBox shape2 = slide1.createTextBox();
|
XSLFTextBox shape2 = slide1.createTextBox();
|
||||||
shape2.setAnchor(new Rectangle(300, 50, 200, 50));
|
shape2.setAnchor(new Rectangle(300, 50, 200, 50));
|
||||||
|
|
|
@ -53,8 +53,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
* now includes the SXSSF which handles all of this for you, you should
|
* now includes the SXSSF which handles all of this for you, you should
|
||||||
* be using that instead! This code remains mostly for historical interest.
|
* be using that instead! This code remains mostly for historical interest.
|
||||||
* <p>
|
* <p>
|
||||||
* See <a "http://poi.apache.org/spreadsheet/how-to.html#sxssf">
|
* See <a "https://poi.apache.org/spreadsheet/how-to.html#sxssf">
|
||||||
* http://poi.apache.org/spreadsheet/how-to.html#sxssf</a>.
|
* https://poi.apache.org/spreadsheet/how-to.html#sxssf</a>.
|
||||||
* <p>
|
* <p>
|
||||||
* If you really want to use this approach, which is also the one that SXSSF
|
* If you really want to use this approach, which is also the one that SXSSF
|
||||||
* does for you, it works as follows:
|
* does for you, it works as follows:
|
||||||
|
@ -72,8 +72,8 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
||||||
* to all rows in the document. Older rows that are no longer in the window
|
* to all rows in the document. Older rows that are no longer in the window
|
||||||
* become inaccessible, as they are written to the disk.
|
* become inaccessible, as they are written to the disk.
|
||||||
* </p>
|
* </p>
|
||||||
* See <a "http://poi.apache.org/spreadsheet/how-to.html#sxssf">
|
* See <a "https://poi.apache.org/spreadsheet/how-to.html#sxssf">
|
||||||
* http://poi.apache.org/spreadsheet/how-to.html#sxssf</a>.
|
* https://poi.apache.org/spreadsheet/how-to.html#sxssf</a>.
|
||||||
*/
|
*/
|
||||||
public final class BigGridDemo {
|
public final class BigGridDemo {
|
||||||
private static final String XML_ENCODING = "UTF-8";
|
private static final String XML_ENCODING = "UTF-8";
|
||||||
|
|
|
@ -54,7 +54,7 @@ public class HyperlinkExample {
|
||||||
cell.setCellValue("URL Link");
|
cell.setCellValue("URL Link");
|
||||||
|
|
||||||
Hyperlink link = createHelper.createHyperlink(HyperlinkType.URL);
|
Hyperlink link = createHelper.createHyperlink(HyperlinkType.URL);
|
||||||
link.setAddress("http://poi.apache.org/");
|
link.setAddress("https://poi.apache.org/");
|
||||||
cell.setHyperlink(link);
|
cell.setHyperlink(link);
|
||||||
cell.setCellStyle(hlink_style);
|
cell.setCellStyle(hlink_style);
|
||||||
|
|
||||||
|
|
|
@ -18,6 +18,6 @@
|
||||||
/**
|
/**
|
||||||
* Horrible SpreadSheet Format API's for reading/writting Excel files using pure Java.
|
* Horrible SpreadSheet Format API's for reading/writting Excel files using pure Java.
|
||||||
*
|
*
|
||||||
* @see <a href="http://poi.apache.org/components/spreadsheet/index.html">Overview, tutorials, examples, guides, and tool documentation</a>
|
* @see <a href="https://poi.apache.org/components/spreadsheet/index.html">Overview, tutorials, examples, guides, and tool documentation</a>
|
||||||
*/
|
*/
|
||||||
package org.apache.poi.hssf;
|
package org.apache.poi.hssf;
|
||||||
|
|
|
@ -29,7 +29,7 @@
|
||||||
* <li>the {@link org.apache.poi.poifs.crypt.xor xor} package contains classes for the xor obfuscation of biff/H**F formats</li>
|
* <li>the {@link org.apache.poi.poifs.crypt.xor xor} package contains classes for the xor obfuscation of biff/H**F formats</li>
|
||||||
* </ul>
|
* </ul>
|
||||||
*
|
*
|
||||||
* @see <a href="http://poi.apache.org/encryption.html">Apache POI - Encryption support</a>
|
* @see <a href="https://poi.apache.org/encryption.html">Apache POI - Encryption support</a>
|
||||||
* @see <a href="http://msdn.microsoft.com/en-us/library/dd952186(v=office.12).aspx">ECMA-376 Document Encryption</a>
|
* @see <a href="http://msdn.microsoft.com/en-us/library/dd952186(v=office.12).aspx">ECMA-376 Document Encryption</a>
|
||||||
*/
|
*/
|
||||||
package org.apache.poi.poifs.crypt;
|
package org.apache.poi.poifs.crypt;
|
|
@ -267,7 +267,7 @@ public class XSSFWorkbook extends POIXMLDocument implements Workbook, Date1904Su
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructs a XSSFWorkbook object given a OpenXML4J <code>Package</code> object,
|
* Constructs a XSSFWorkbook object given a OpenXML4J <code>Package</code> object,
|
||||||
* see <a href="http://poi.apache.org/oxml4j/">http://poi.apache.org/oxml4j/</a>.
|
* see <a href="https://poi.apache.org/oxml4j/">https://poi.apache.org/oxml4j/</a>.
|
||||||
*
|
*
|
||||||
* <p>Once you have finished working with the Workbook, you should close the package
|
* <p>Once you have finished working with the Workbook, you should close the package
|
||||||
* by calling either {@link #close()} or {@link OPCPackage#close()}, to avoid
|
* by calling either {@link #close()} or {@link OPCPackage#close()}, to avoid
|
||||||
|
|
|
@ -211,7 +211,7 @@ public class TestXSLFBugs {
|
||||||
XSLFTextRun r = p.addNewTextRun();
|
XSLFTextRun r = p.addNewTextRun();
|
||||||
p.addLineBreak();
|
p.addLineBreak();
|
||||||
r.setText("Apache POI");
|
r.setText("Apache POI");
|
||||||
r.createHyperlink().setAddress("http://poi.apache.org");
|
r.createHyperlink().setAddress("https://poi.apache.org");
|
||||||
// create hyperlink pointing to a page, which isn't available at the time of importing the content
|
// create hyperlink pointing to a page, which isn't available at the time of importing the content
|
||||||
r = p.addNewTextRun();
|
r = p.addNewTextRun();
|
||||||
r.setText("Slide 2");
|
r.setText("Slide 2");
|
||||||
|
@ -233,7 +233,7 @@ public class TestXSLFBugs {
|
||||||
XSLFTextParagraph p = shape.getTextParagraphs().get(1);
|
XSLFTextParagraph p = shape.getTextParagraphs().get(1);
|
||||||
XSLFHyperlink h1 = p.getTextRuns().get(0).getHyperlink();
|
XSLFHyperlink h1 = p.getTextRuns().get(0).getHyperlink();
|
||||||
assertNotNull(h1);
|
assertNotNull(h1);
|
||||||
assertEquals("http://poi.apache.org", h1.getAddress());
|
assertEquals("https://poi.apache.org", h1.getAddress());
|
||||||
XSLFHyperlink h2 = p.getTextRuns().get(2).getHyperlink();
|
XSLFHyperlink h2 = p.getTextRuns().get(2).getHyperlink();
|
||||||
assertNotNull(h2);
|
assertNotNull(h2);
|
||||||
// relative url will be resolved to an absolute url, therefore this doesn't equals to "slide2.xml"
|
// relative url will be resolved to an absolute url, therefore this doesn't equals to "slide2.xml"
|
||||||
|
@ -724,8 +724,8 @@ public class TestXSLFBugs {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void bug59434() throws IOException {
|
public void bug59434() throws IOException {
|
||||||
String url1 = "http://poi.apache.org/changes.html";
|
String url1 = "https://poi.apache.org/changes.html";
|
||||||
String url2 = "http://poi.apache.org/faq.html";
|
String url2 = "https://poi.apache.org/faq.html";
|
||||||
XMLSlideShow ppt1 = new XMLSlideShow();
|
XMLSlideShow ppt1 = new XMLSlideShow();
|
||||||
PictureData pd1 = ppt1.addPicture(slTests.readFile("tomcat.png"), PictureType.PNG);
|
PictureData pd1 = ppt1.addPicture(slTests.readFile("tomcat.png"), PictureType.PNG);
|
||||||
PictureData pd2 = ppt1.addPicture(slTests.readFile("santa.wmf"), PictureType.WMF);
|
PictureData pd2 = ppt1.addPicture(slTests.readFile("santa.wmf"), PictureType.WMF);
|
||||||
|
|
|
@ -56,7 +56,7 @@ public class TestXSLFHyperlink {
|
||||||
XSLFHyperlink link3 = cell3.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
|
XSLFHyperlink link3 = cell3.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
|
||||||
assertNotNull(link3);
|
assertNotNull(link3);
|
||||||
assertEquals("mailto:dev@poi.apache.org?subject=Hi%20There", link3.getAddress());
|
assertEquals("mailto:dev@poi.apache.org?subject=Hi%20There", link3.getAddress());
|
||||||
|
|
||||||
ppt.close();
|
ppt.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -99,7 +99,7 @@ public class TestXSLFHyperlink {
|
||||||
assertEquals(id2, rel2.getId());
|
assertEquals(id2, rel2.getId());
|
||||||
assertEquals(TargetMode.INTERNAL, rel2.getTargetMode());
|
assertEquals(TargetMode.INTERNAL, rel2.getTargetMode());
|
||||||
assertEquals(XSLFRelation.SLIDE.getRelation(), rel2.getRelationshipType());
|
assertEquals(XSLFRelation.SLIDE.getRelation(), rel2.getRelationshipType());
|
||||||
|
|
||||||
ppt.close();
|
ppt.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -174,7 +174,7 @@ public class TestXSLFHyperlink {
|
||||||
assertNotNull(hl5);
|
assertNotNull(hl5);
|
||||||
assertEquals("firstslide", hl5.getXmlObject().getAction().split("=")[1]);
|
assertEquals("firstslide", hl5.getXmlObject().getAction().split("=")[1]);
|
||||||
assertEquals(HyperlinkType.DOCUMENT, hl5.getType());
|
assertEquals(HyperlinkType.DOCUMENT, hl5.getType());
|
||||||
|
|
||||||
ppt2.close();
|
ppt2.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -265,7 +265,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||||
XSSFWorkbook wb2 = (XSSFWorkbook)_testDataProvider.writeOutAndReadBack(wb1);
|
XSSFWorkbook wb2 = (XSSFWorkbook)_testDataProvider.writeOutAndReadBack(wb1);
|
||||||
row = wb2.getSheetAt(0).getRow(0);
|
row = wb2.getSheetAt(0).getRow(0);
|
||||||
assertCellsWithMissingR(row);
|
assertCellsWithMissingR(row);
|
||||||
|
|
||||||
wb2.close();
|
wb2.close();
|
||||||
wb1.close();
|
wb1.close();
|
||||||
}
|
}
|
||||||
|
@ -338,7 +338,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||||
wbRef.close();
|
wbRef.close();
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test56170() throws IOException {
|
public void test56170() throws IOException {
|
||||||
final Workbook wb1 = XSSFTestDataSamples.openSampleWorkbook("56170.xlsx");
|
final Workbook wb1 = XSSFTestDataSamples.openSampleWorkbook("56170.xlsx");
|
||||||
|
@ -346,7 +346,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||||
|
|
||||||
Workbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1);
|
Workbook wb2 = XSSFTestDataSamples.writeOutAndReadBack(wb1);
|
||||||
Cell cell;
|
Cell cell;
|
||||||
|
|
||||||
// add some contents to table so that the table will need expansion
|
// add some contents to table so that the table will need expansion
|
||||||
Row row = sheet.getRow(0);
|
Row row = sheet.getRow(0);
|
||||||
Workbook wb3 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
|
Workbook wb3 = XSSFTestDataSamples.writeOutAndReadBack(wb2);
|
||||||
|
@ -363,7 +363,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||||
cell.setCellValue("demo3");
|
cell.setCellValue("demo3");
|
||||||
|
|
||||||
Workbook wb9 = XSSFTestDataSamples.writeOutAndReadBack(wb8);
|
Workbook wb9 = XSSFTestDataSamples.writeOutAndReadBack(wb8);
|
||||||
|
|
||||||
row = sheet.getRow(1);
|
row = sheet.getRow(1);
|
||||||
cell = row.createCell(0);
|
cell = row.createCell(0);
|
||||||
cell.setCellValue("demo1");
|
cell.setCellValue("demo1");
|
||||||
|
@ -373,7 +373,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||||
cell.setCellValue("demo3");
|
cell.setCellValue("demo3");
|
||||||
|
|
||||||
Workbook wb10 = XSSFTestDataSamples.writeOutAndReadBack(wb9);
|
Workbook wb10 = XSSFTestDataSamples.writeOutAndReadBack(wb9);
|
||||||
|
|
||||||
// expand table
|
// expand table
|
||||||
XSSFTable table = sheet.getTables().get(0);
|
XSSFTable table = sheet.getTables().get(0);
|
||||||
final CellReference startRef = table.getStartCellReference();
|
final CellReference startRef = table.getStartCellReference();
|
||||||
|
@ -395,7 +395,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||||
wb2.close();
|
wb2.close();
|
||||||
wb1.close();
|
wb1.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test56170Reproduce() throws IOException {
|
public void test56170Reproduce() throws IOException {
|
||||||
try (Workbook wb = new XSSFWorkbook()) {
|
try (Workbook wb = new XSSFWorkbook()) {
|
||||||
|
@ -437,11 +437,11 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||||
private void validateRow(Row row) {
|
private void validateRow(Row row) {
|
||||||
// trigger bug with CArray handling
|
// trigger bug with CArray handling
|
||||||
((XSSFRow)row).onDocumentWrite();
|
((XSSFRow)row).onDocumentWrite();
|
||||||
|
|
||||||
for(Cell cell : row) {
|
for(Cell cell : row) {
|
||||||
assertNotNull(cell.toString());
|
assertNotNull(cell.toString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testBug56644ReturnNull() throws IOException {
|
public void testBug56644ReturnNull() throws IOException {
|
||||||
|
@ -526,59 +526,59 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||||
}
|
}
|
||||||
|
|
||||||
private XSSFCell srcCell, destCell; //used for testCopyCellFrom_CellCopyPolicy
|
private XSSFCell srcCell, destCell; //used for testCopyCellFrom_CellCopyPolicy
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void testCopyCellFrom_CellCopyPolicy_default() {
|
public final void testCopyCellFrom_CellCopyPolicy_default() {
|
||||||
setUp_testCopyCellFrom_CellCopyPolicy();
|
setUp_testCopyCellFrom_CellCopyPolicy();
|
||||||
|
|
||||||
// default copy policy
|
// default copy policy
|
||||||
final CellCopyPolicy policy = new CellCopyPolicy();
|
final CellCopyPolicy policy = new CellCopyPolicy();
|
||||||
destCell.copyCellFrom(srcCell, policy);
|
destCell.copyCellFrom(srcCell, policy);
|
||||||
|
|
||||||
assertEquals(CellType.FORMULA, destCell.getCellType());
|
assertEquals(CellType.FORMULA, destCell.getCellType());
|
||||||
assertEquals("2+3", destCell.getCellFormula());
|
assertEquals("2+3", destCell.getCellFormula());
|
||||||
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
|
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void testCopyCellFrom_CellCopyPolicy_value() {
|
public final void testCopyCellFrom_CellCopyPolicy_value() {
|
||||||
setUp_testCopyCellFrom_CellCopyPolicy();
|
setUp_testCopyCellFrom_CellCopyPolicy();
|
||||||
|
|
||||||
// Paste values only
|
// Paste values only
|
||||||
final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(false).build();
|
final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(false).build();
|
||||||
destCell.copyCellFrom(srcCell, policy);
|
destCell.copyCellFrom(srcCell, policy);
|
||||||
assertEquals(CellType.NUMERIC, destCell.getCellType());
|
assertEquals(CellType.NUMERIC, destCell.getCellType());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void testCopyCellFrom_CellCopyPolicy_formulaWithUnregisteredUDF() {
|
public final void testCopyCellFrom_CellCopyPolicy_formulaWithUnregisteredUDF() {
|
||||||
setUp_testCopyCellFrom_CellCopyPolicy();
|
setUp_testCopyCellFrom_CellCopyPolicy();
|
||||||
|
|
||||||
srcCell.setCellFormula("MYFUNC2(123, $A5, Sheet1!$B7)");
|
srcCell.setCellFormula("MYFUNC2(123, $A5, Sheet1!$B7)");
|
||||||
|
|
||||||
// Copy formula verbatim (no shifting). This is okay because copyCellFrom is Internal.
|
// Copy formula verbatim (no shifting). This is okay because copyCellFrom is Internal.
|
||||||
// Users should use higher-level copying functions to row- or column-shift formulas.
|
// Users should use higher-level copying functions to row- or column-shift formulas.
|
||||||
final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(true).build();
|
final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellFormula(true).build();
|
||||||
destCell.copyCellFrom(srcCell, policy);
|
destCell.copyCellFrom(srcCell, policy);
|
||||||
assertEquals("MYFUNC2(123, $A5, Sheet1!$B7)", destCell.getCellFormula());
|
assertEquals("MYFUNC2(123, $A5, Sheet1!$B7)", destCell.getCellFormula());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void testCopyCellFrom_CellCopyPolicy_style() {
|
public final void testCopyCellFrom_CellCopyPolicy_style() {
|
||||||
setUp_testCopyCellFrom_CellCopyPolicy();
|
setUp_testCopyCellFrom_CellCopyPolicy();
|
||||||
srcCell.setCellValue((String) null);
|
srcCell.setCellValue((String) null);
|
||||||
|
|
||||||
// Paste styles only
|
// Paste styles only
|
||||||
final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellValue(false).build();
|
final CellCopyPolicy policy = new CellCopyPolicy.Builder().cellValue(false).build();
|
||||||
destCell.copyCellFrom(srcCell, policy);
|
destCell.copyCellFrom(srcCell, policy);
|
||||||
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
|
assertEquals(srcCell.getCellStyle(), destCell.getCellStyle());
|
||||||
|
|
||||||
// Old cell value should not have been overwritten
|
// Old cell value should not have been overwritten
|
||||||
assertNotEquals(CellType.BLANK, destCell.getCellType());
|
assertNotEquals(CellType.BLANK, destCell.getCellType());
|
||||||
assertEquals(CellType.BOOLEAN, destCell.getCellType());
|
assertEquals(CellType.BOOLEAN, destCell.getCellType());
|
||||||
assertTrue(destCell.getBooleanCellValue());
|
assertTrue(destCell.getBooleanCellValue());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public final void testCopyCellFrom_CellCopyPolicy_copyHyperlink() throws IOException {
|
public final void testCopyCellFrom_CellCopyPolicy_copyHyperlink() throws IOException {
|
||||||
setUp_testCopyCellFrom_CellCopyPolicy();
|
setUp_testCopyCellFrom_CellCopyPolicy();
|
||||||
|
@ -587,7 +587,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||||
|
|
||||||
srcCell.setCellValue("URL LINK");
|
srcCell.setCellValue("URL LINK");
|
||||||
Hyperlink link = createHelper.createHyperlink(HyperlinkType.URL);
|
Hyperlink link = createHelper.createHyperlink(HyperlinkType.URL);
|
||||||
link.setAddress("http://poi.apache.org/");
|
link.setAddress("https://poi.apache.org/");
|
||||||
srcCell.setHyperlink(link);
|
srcCell.setHyperlink(link);
|
||||||
|
|
||||||
// Set link cell style (optional)
|
// Set link cell style (optional)
|
||||||
|
@ -607,7 +607,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||||
new CellAddress(srcCell).formatAsString(), links.get(0).getCellRef());
|
new CellAddress(srcCell).formatAsString(), links.get(0).getCellRef());
|
||||||
assertEquals("destination hyperlink",
|
assertEquals("destination hyperlink",
|
||||||
new CellAddress(destCell).formatAsString(), links.get(1).getCellRef());
|
new CellAddress(destCell).formatAsString(), links.get(1).getCellRef());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -628,7 +628,7 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||||
|
|
||||||
srcCell.setCellValue("URL LINK");
|
srcCell.setCellValue("URL LINK");
|
||||||
Hyperlink link = createHelper.createHyperlink(HyperlinkType.URL);
|
Hyperlink link = createHelper.createHyperlink(HyperlinkType.URL);
|
||||||
link.setAddress("http://poi.apache.org/");
|
link.setAddress("https://poi.apache.org/");
|
||||||
destCell.setHyperlink(link);
|
destCell.setHyperlink(link);
|
||||||
|
|
||||||
// Set link cell style (optional)
|
// Set link cell style (optional)
|
||||||
|
@ -651,36 +651,36 @@ public final class TestXSSFCell extends BaseTestXCell {
|
||||||
assertEquals("number of hyperlinks on sheet", 1, links.size());
|
assertEquals("number of hyperlinks on sheet", 1, links.size());
|
||||||
assertEquals("source hyperlink",
|
assertEquals("source hyperlink",
|
||||||
new CellAddress(destCell).formatAsString(), links.get(0).getCellRef());
|
new CellAddress(destCell).formatAsString(), links.get(0).getCellRef());
|
||||||
|
|
||||||
// Merge destCell's hyperlink to srcCell. Since destCell does have a hyperlink, this should copy destCell's hyperlink to srcCell.
|
// Merge destCell's hyperlink to srcCell. Since destCell does have a hyperlink, this should copy destCell's hyperlink to srcCell.
|
||||||
srcCell.copyCellFrom(destCell, policy);
|
srcCell.copyCellFrom(destCell, policy);
|
||||||
assertNotNull(srcCell.getHyperlink());
|
assertNotNull(srcCell.getHyperlink());
|
||||||
assertNotNull(destCell.getHyperlink());
|
assertNotNull(destCell.getHyperlink());
|
||||||
|
|
||||||
links = srcCell.getSheet().getHyperlinkList();
|
links = srcCell.getSheet().getHyperlinkList();
|
||||||
assertEquals("number of hyperlinks on sheet", 2, links.size());
|
assertEquals("number of hyperlinks on sheet", 2, links.size());
|
||||||
assertEquals("dest hyperlink",
|
assertEquals("dest hyperlink",
|
||||||
new CellAddress(destCell).formatAsString(), links.get(0).getCellRef());
|
new CellAddress(destCell).formatAsString(), links.get(0).getCellRef());
|
||||||
assertEquals("source hyperlink",
|
assertEquals("source hyperlink",
|
||||||
new CellAddress(srcCell).formatAsString(), links.get(1).getCellRef());
|
new CellAddress(srcCell).formatAsString(), links.get(1).getCellRef());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setUp_testCopyCellFrom_CellCopyPolicy() {
|
private void setUp_testCopyCellFrom_CellCopyPolicy() {
|
||||||
@SuppressWarnings("resource")
|
@SuppressWarnings("resource")
|
||||||
final XSSFWorkbook wb = new XSSFWorkbook();
|
final XSSFWorkbook wb = new XSSFWorkbook();
|
||||||
final XSSFRow row = wb.createSheet("Sheet1").createRow(0);
|
final XSSFRow row = wb.createSheet("Sheet1").createRow(0);
|
||||||
srcCell = row.createCell(0);
|
srcCell = row.createCell(0);
|
||||||
destCell = row.createCell(1);
|
destCell = row.createCell(1);
|
||||||
|
|
||||||
srcCell.setCellFormula("2+3");
|
srcCell.setCellFormula("2+3");
|
||||||
|
|
||||||
final CellStyle style = wb.createCellStyle();
|
final CellStyle style = wb.createCellStyle();
|
||||||
style.setBorderTop(BorderStyle.THICK);
|
style.setBorderTop(BorderStyle.THICK);
|
||||||
style.setFillBackgroundColor((short) 5);
|
style.setFillBackgroundColor((short) 5);
|
||||||
srcCell.setCellStyle(style);
|
srcCell.setCellStyle(style);
|
||||||
|
|
||||||
destCell.setCellValue(true);
|
destCell.setCellValue(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
|
||||||
XSSFSheet sheet = workbook.createSheet();
|
XSSFSheet sheet = workbook.createSheet();
|
||||||
XSSFRow row = sheet.createRow(0);
|
XSSFRow row = sheet.createRow(0);
|
||||||
XSSFCreationHelper createHelper = workbook.getCreationHelper();
|
XSSFCreationHelper createHelper = workbook.getCreationHelper();
|
||||||
|
|
||||||
String[] urls = {
|
String[] urls = {
|
||||||
"http://apache.org",
|
"http://apache.org",
|
||||||
"www.apache.org",
|
"www.apache.org",
|
||||||
|
@ -273,12 +273,12 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public XSSFHyperlink copyHyperlink(Hyperlink link) {
|
public XSSFHyperlink copyHyperlink(Hyperlink link) {
|
||||||
return new XSSFHyperlink(link);
|
return new XSSFHyperlink(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testCopyHSSFHyperlink() throws IOException {
|
public void testCopyHSSFHyperlink() throws IOException {
|
||||||
HSSFWorkbook hssfworkbook = new HSSFWorkbook();
|
HSSFWorkbook hssfworkbook = new HSSFWorkbook();
|
||||||
|
@ -290,15 +290,15 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
|
||||||
hlink.setLastRow(6);
|
hlink.setLastRow(6);
|
||||||
hlink.setLabel("label");
|
hlink.setLabel("label");
|
||||||
XSSFHyperlink xlink = new XSSFHyperlink(hlink);
|
XSSFHyperlink xlink = new XSSFHyperlink(hlink);
|
||||||
|
|
||||||
assertEquals("http://poi.apache.org/", xlink.getAddress());
|
assertEquals("http://poi.apache.org/", xlink.getAddress());
|
||||||
assertEquals(new CellReference(2, 3), new CellReference(xlink.getCellRef()));
|
assertEquals(new CellReference(2, 3), new CellReference(xlink.getCellRef()));
|
||||||
// Are HSSFHyperlink.label and XSSFHyperlink.tooltip the same? If so, perhaps one of these needs renamed for a consistent Hyperlink interface
|
// Are HSSFHyperlink.label and XSSFHyperlink.tooltip the same? If so, perhaps one of these needs renamed for a consistent Hyperlink interface
|
||||||
// assertEquals("label", xlink.getTooltip());
|
// assertEquals("label", xlink.getTooltip());
|
||||||
|
|
||||||
hssfworkbook.close();
|
hssfworkbook.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bug 59775: XSSFHyperlink has wrong type if it contains a location (CTHyperlink#getLocation)
|
/* bug 59775: XSSFHyperlink has wrong type if it contains a location (CTHyperlink#getLocation)
|
||||||
* URLs with a hash mark (#) are still URL hyperlinks, not document links
|
* URLs with a hash mark (#) are still URL hyperlinks, not document links
|
||||||
*/
|
*/
|
||||||
|
@ -310,27 +310,27 @@ public final class TestXSSFHyperlink extends BaseTestHyperlink {
|
||||||
CellAddress A3 = new CellAddress("A3");
|
CellAddress A3 = new CellAddress("A3");
|
||||||
CellAddress A4 = new CellAddress("A4");
|
CellAddress A4 = new CellAddress("A4");
|
||||||
CellAddress A7 = new CellAddress("A7");
|
CellAddress A7 = new CellAddress("A7");
|
||||||
|
|
||||||
XSSFHyperlink link = sh.getHyperlink(A2);
|
XSSFHyperlink link = sh.getHyperlink(A2);
|
||||||
assertEquals("address", "A2", link.getCellRef());
|
assertEquals("address", "A2", link.getCellRef());
|
||||||
assertEquals("link type", HyperlinkType.URL, link.getType());
|
assertEquals("link type", HyperlinkType.URL, link.getType());
|
||||||
assertEquals("link target", "http://twitter.com/#!/apacheorg", link.getAddress());
|
assertEquals("link target", "http://twitter.com/#!/apacheorg", link.getAddress());
|
||||||
|
|
||||||
link = sh.getHyperlink(A3);
|
link = sh.getHyperlink(A3);
|
||||||
assertEquals("address", "A3", link.getCellRef());
|
assertEquals("address", "A3", link.getCellRef());
|
||||||
assertEquals("link type", HyperlinkType.URL, link.getType());
|
assertEquals("link type", HyperlinkType.URL, link.getType());
|
||||||
assertEquals("link target", "http://www.bailii.org/databases.html#ie", link.getAddress());
|
assertEquals("link target", "http://www.bailii.org/databases.html#ie", link.getAddress());
|
||||||
|
|
||||||
link = sh.getHyperlink(A4);
|
link = sh.getHyperlink(A4);
|
||||||
assertEquals("address", "A4", link.getCellRef());
|
assertEquals("address", "A4", link.getCellRef());
|
||||||
assertEquals("link type", HyperlinkType.URL, link.getType());
|
assertEquals("link type", HyperlinkType.URL, link.getType());
|
||||||
assertEquals("link target", "https://en.wikipedia.org/wiki/Apache_POI#See_also", link.getAddress());
|
assertEquals("link target", "https://en.wikipedia.org/wiki/Apache_POI#See_also", link.getAddress());
|
||||||
|
|
||||||
link = sh.getHyperlink(A7);
|
link = sh.getHyperlink(A7);
|
||||||
assertEquals("address", "A7", link.getCellRef());
|
assertEquals("address", "A7", link.getCellRef());
|
||||||
assertEquals("link type", HyperlinkType.DOCUMENT, link.getType());
|
assertEquals("link type", HyperlinkType.DOCUMENT, link.getType());
|
||||||
assertEquals("link target", "Sheet1", link.getAddress());
|
assertEquals("link target", "Sheet1", link.getAddress());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -65,7 +65,7 @@ public final class TestXWPFDocument {
|
||||||
// }
|
// }
|
||||||
}
|
}
|
||||||
assertTrue(found);
|
assertTrue(found);
|
||||||
|
|
||||||
pack.close();
|
pack.close();
|
||||||
doc.close();
|
doc.close();
|
||||||
}
|
}
|
||||||
|
@ -195,12 +195,17 @@ public final class TestXWPFDocument {
|
||||||
public void testAddHyperlink() throws IOException {
|
public void testAddHyperlink() throws IOException {
|
||||||
try (XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("SampleDoc.docx")) {
|
try (XWPFDocument doc = XWPFTestDataSamples.openSampleDocument("SampleDoc.docx")) {
|
||||||
XWPFParagraph p = doc.createParagraph();
|
XWPFParagraph p = doc.createParagraph();
|
||||||
XWPFHyperlinkRun h = p.createHyperlinkRun("http://poi.apache.org/");
|
XWPFHyperlinkRun h = p.createHyperlinkRun("https://poi.apache.org/");
|
||||||
h.setText("Apache POI");
|
h.setText("Apache POI");
|
||||||
|
|
||||||
assertEquals("http://poi.apache.org/", h.getHyperlink(doc).getURL());
|
assertEquals("https://poi.apache.org/", h.getHyperlink(doc).getURL());
|
||||||
assertEquals(p.getRuns().size(), 1);
|
assertEquals(p.getRuns().size(), 1);
|
||||||
assertEquals(p.getRuns().get(0), h);
|
assertEquals(p.getRuns().get(0), h);
|
||||||
|
|
||||||
|
h = p.createHyperlinkRun("https://poi.apache.org/");
|
||||||
|
h.setText("Apache POI");
|
||||||
|
|
||||||
|
assertEquals("rId8", h.getHyperlinkId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -456,14 +461,14 @@ public final class TestXWPFDocument {
|
||||||
|
|
||||||
doc.close();
|
doc.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testEnforcedWith() throws IOException {
|
public void testEnforcedWith() throws IOException {
|
||||||
try (XWPFDocument docx = XWPFTestDataSamples.openSampleDocument("EnforcedWith.docx")) {
|
try (XWPFDocument docx = XWPFTestDataSamples.openSampleDocument("EnforcedWith.docx")) {
|
||||||
assertTrue(docx.isEnforcedProtection());
|
assertTrue(docx.isEnforcedProtection());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@Ignore("XWPF should be able to write to a new Stream when opened Read-Only")
|
@Ignore("XWPF should be able to write to a new Stream when opened Read-Only")
|
||||||
public void testWriteFromReadOnlyOPC() throws Exception {
|
public void testWriteFromReadOnlyOPC() throws Exception {
|
||||||
|
|
|
@ -32,7 +32,7 @@ import org.junit.Test;
|
||||||
public final class TestPublisherTextExtractor {
|
public final class TestPublisherTextExtractor {
|
||||||
private static final POIDataSamples _samples = POIDataSamples.getPublisherInstance();
|
private static final POIDataSamples _samples = POIDataSamples.getPublisherInstance();
|
||||||
|
|
||||||
private static final String SAMPLE_TEXT =
|
private static final String SAMPLE_TEXT =
|
||||||
"This is some text on the first page\n" +
|
"This is some text on the first page\n" +
|
||||||
"It\u2019s in times new roman, font size 10, all normal\n" +
|
"It\u2019s in times new roman, font size 10, all normal\n" +
|
||||||
"" +
|
"" +
|
||||||
|
@ -154,7 +154,7 @@ public final class TestPublisherTextExtractor {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testWithHyperlinks() throws Exception {
|
public void testWithHyperlinks() throws Exception {
|
||||||
InputStream linkAt = _samples.openResourceAsStream("LinkAt10.pub");
|
InputStream linkAt = _samples.openResourceAsStream("LinkAt10.pub");
|
||||||
HPBFDocument doc = new HPBFDocument(linkAt);
|
HPBFDocument doc = new HPBFDocument(linkAt);
|
||||||
|
|
||||||
PublisherTextExtractor ext = new PublisherTextExtractor(doc);
|
PublisherTextExtractor ext = new PublisherTextExtractor(doc);
|
||||||
|
|
|
@ -68,7 +68,7 @@ public final class TestQuillContents {
|
||||||
assertEquals("STSH", qc.getBits()[3].getThingType());
|
assertEquals("STSH", qc.getBits()[3].getThingType());
|
||||||
assertEquals("STSH", qc.getBits()[3].getBitType());
|
assertEquals("STSH", qc.getBits()[3].getBitType());
|
||||||
assertEquals(2, qc.getBits()[3].getOptA());
|
assertEquals(2, qc.getBits()[3].getOptA());
|
||||||
|
|
||||||
doc.close();
|
doc.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -85,7 +85,7 @@ public final class TestQuillContents {
|
||||||
String t = text.getText();
|
String t = text.getText();
|
||||||
assertStartsWith(t, "This is some text on the first page");
|
assertStartsWith(t, "This is some text on the first page");
|
||||||
assertEndsWith(t, "Within doc to page 1\r");
|
assertEndsWith(t, "Within doc to page 1\r");
|
||||||
|
|
||||||
doc.close();
|
doc.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -148,7 +148,7 @@ public final class TestQuillContents {
|
||||||
assertEquals(0x22000000, plc12.getPlcValB()[0]);
|
assertEquals(0x22000000, plc12.getPlcValB()[0]);
|
||||||
assertEquals(0x05, plc12.getPlcValA()[1]);
|
assertEquals(0x05, plc12.getPlcValA()[1]);
|
||||||
assertEquals(0x04, plc12.getPlcValB()[1]);
|
assertEquals(0x04, plc12.getPlcValB()[1]);
|
||||||
|
|
||||||
doc.close();
|
doc.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -253,7 +253,7 @@ public final class TestQuillContents {
|
||||||
assertEquals(0x000004, plc16.getPlcValB()[4]);
|
assertEquals(0x000004, plc16.getPlcValB()[4]);
|
||||||
assertEquals(0x000004, plc16.getPlcValA()[5]);
|
assertEquals(0x000004, plc16.getPlcValA()[5]);
|
||||||
assertEquals(0x000004, plc16.getPlcValB()[5]);
|
assertEquals(0x000004, plc16.getPlcValB()[5]);
|
||||||
|
|
||||||
doc.close();
|
doc.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -272,7 +272,7 @@ public final class TestQuillContents {
|
||||||
assertEquals(0, plc18.getNumberOfHyperlinks());
|
assertEquals(0, plc18.getNumberOfHyperlinks());
|
||||||
assertEquals(0, plc18.getTextStartAt(0));
|
assertEquals(0, plc18.getTextStartAt(0));
|
||||||
assertEquals(601, plc18.getAllTextEndAt());
|
assertEquals(601, plc18.getAllTextEndAt());
|
||||||
|
|
||||||
doc.close();
|
doc.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -347,7 +347,7 @@ public final class TestQuillContents {
|
||||||
assertEquals(10, hlBit.getTextStartAt(0));
|
assertEquals(10, hlBit.getTextStartAt(0));
|
||||||
assertEquals(15, hlBit.getAllTextEndAt());
|
assertEquals(15, hlBit.getAllTextEndAt());
|
||||||
assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
|
assertEquals("http://poi.apache.org/", hlBit.getHyperlink(0));
|
||||||
|
|
||||||
doc.close();
|
doc.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -91,7 +91,7 @@ public final class TestHyperlink {
|
||||||
assertEquals("Open Jakarta POI HSSF module test ", links.get(0).getLabel());
|
assertEquals("Open Jakarta POI HSSF module test ", links.get(0).getLabel());
|
||||||
assertEquals("http://jakarta.apache.org/poi/hssf/", links.get(0).getAddress());
|
assertEquals("http://jakarta.apache.org/poi/hssf/", links.get(0).getAddress());
|
||||||
assertEquals("Jakarta HSSF", rawText.substring(links.get(0).getStartIndex(), links.get(0).getEndIndex()-1));
|
assertEquals("Jakarta HSSF", rawText.substring(links.get(0).getStartIndex(), links.get(0).getEndIndex()-1));
|
||||||
|
|
||||||
ppt.close();
|
ppt.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -115,7 +115,7 @@ public final class TestHyperlink {
|
||||||
hl3.linkToSlide(slide1);
|
hl3.linkToSlide(slide1);
|
||||||
HSLFTextRun r4 = ppt1.createSlide().createTextBox().setText("page4");
|
HSLFTextRun r4 = ppt1.createSlide().createTextBox().setText("page4");
|
||||||
HSLFHyperlink hl4 = r4.createHyperlink();
|
HSLFHyperlink hl4 = r4.createHyperlink();
|
||||||
hl4.linkToUrl("http://poi.apache.org");
|
hl4.linkToUrl("https://poi.apache.org");
|
||||||
HSLFTextBox tb5 = ppt1.createSlide().createTextBox();
|
HSLFTextBox tb5 = ppt1.createSlide().createTextBox();
|
||||||
tb5.setText("page5");
|
tb5.setText("page5");
|
||||||
HSLFHyperlink hl5 = tb5.createHyperlink();
|
HSLFHyperlink hl5 = tb5.createHyperlink();
|
||||||
|
@ -146,7 +146,7 @@ public final class TestHyperlink {
|
||||||
HSLFTextBox tb4 = (HSLFTextBox)slides.get(3).getShapes().get(0);
|
HSLFTextBox tb4 = (HSLFTextBox)slides.get(3).getShapes().get(0);
|
||||||
hl4 = tb4.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
|
hl4 = tb4.getTextParagraphs().get(0).getTextRuns().get(0).getHyperlink();
|
||||||
assertNotNull(hl4);
|
assertNotNull(hl4);
|
||||||
assertEquals("http://poi.apache.org", hl4.getLabel());
|
assertEquals("https://poi.apache.org", hl4.getLabel());
|
||||||
assertEquals(HyperlinkType.URL, hl4.getType());
|
assertEquals(HyperlinkType.URL, hl4.getType());
|
||||||
|
|
||||||
tb5 = (HSLFTextBox)slides.get(4).getShapes().get(0);
|
tb5 = (HSLFTextBox)slides.get(4).getShapes().get(0);
|
||||||
|
@ -154,10 +154,10 @@ public final class TestHyperlink {
|
||||||
assertNotNull(hl5);
|
assertNotNull(hl5);
|
||||||
assertEquals(InteractiveInfoAtom.LINK_FirstSlide, hl5.getInfo().getInteractiveInfoAtom().getHyperlinkType());
|
assertEquals(InteractiveInfoAtom.LINK_FirstSlide, hl5.getInfo().getInteractiveInfoAtom().getHyperlinkType());
|
||||||
assertEquals(HyperlinkType.DOCUMENT, hl5.getType());
|
assertEquals(HyperlinkType.DOCUMENT, hl5.getType());
|
||||||
|
|
||||||
ppt2.close();
|
ppt2.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
private static List<HSLFHyperlink> findHyperlinks(List<HSLFTextParagraph> paras) {
|
private static List<HSLFHyperlink> findHyperlinks(List<HSLFTextParagraph> paras) {
|
||||||
List<HSLFHyperlink> links = new ArrayList<>();
|
List<HSLFHyperlink> links = new ArrayList<>();
|
||||||
for (HSLFTextParagraph p : paras) {
|
for (HSLFTextParagraph p : paras) {
|
||||||
|
|
|
@ -2693,7 +2693,7 @@ public final class TestBugs extends BaseTestBugzillaIssues {
|
||||||
try (Workbook wb = openSampleWorkbook("46515.xls")) {
|
try (Workbook wb = openSampleWorkbook("46515.xls")) {
|
||||||
|
|
||||||
// Get structure from webservice
|
// Get structure from webservice
|
||||||
String urlString = "http://poi.apache.org/components/spreadsheet/images/calendar.jpg";
|
String urlString = "https://poi.apache.org/components/spreadsheet/images/calendar.jpg";
|
||||||
URL structURL = new URL(urlString);
|
URL structURL = new URL(urlString);
|
||||||
BufferedImage bimage;
|
BufferedImage bimage;
|
||||||
try {
|
try {
|
||||||
|
|
|
@ -29,13 +29,13 @@ import org.junit.Test;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Tests to show that our documentation at
|
* Tests to show that our documentation at
|
||||||
* http://poi.apache.org/hssf/eval.html
|
* https://poi.apache.org/hssf/eval.html
|
||||||
* all actually works as we'd expect them to
|
* all actually works as we'd expect them to
|
||||||
*/
|
*/
|
||||||
public final class TestFormulaEvaluatorDocs {
|
public final class TestFormulaEvaluatorDocs {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http://poi.apache.org/hssf/eval.html#EvaluateAll
|
* https://poi.apache.org/hssf/eval.html#EvaluateAll
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testEvaluateAll() throws IOException {
|
public void testEvaluateAll() throws IOException {
|
||||||
|
|
|
@ -124,7 +124,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink {
|
||||||
* link.setTextMark("'Target Sheet-1'!A1"); //HSSF-specific
|
* link.setTextMark("'Target Sheet-1'!A1"); //HSSF-specific
|
||||||
* or
|
* or
|
||||||
* link.setAddress("'Target Sheet-1'!A1"); //common between XSSF and HSSF
|
* link.setAddress("'Target Sheet-1'!A1"); //common between XSSF and HSSF
|
||||||
* @throws IOException
|
* @throws IOException
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void testCreateDocumentLink() throws IOException {
|
public void testCreateDocumentLink() throws IOException {
|
||||||
|
@ -155,7 +155,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink {
|
||||||
|
|
||||||
HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||||
wb.close();
|
wb.close();
|
||||||
|
|
||||||
sheet = wbBack.getSheet("Hyperlinks");
|
sheet = wbBack.getSheet("Hyperlinks");
|
||||||
|
|
||||||
cell = sheet.getRow(0).getCell(0);
|
cell = sheet.getRow(0).getCell(0);
|
||||||
|
@ -169,7 +169,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink {
|
||||||
assertNotNull(link);
|
assertNotNull(link);
|
||||||
assertEquals("'Hyperlinks'!A1", link.getTextMark());
|
assertEquals("'Hyperlinks'!A1", link.getTextMark());
|
||||||
assertEquals("'Hyperlinks'!A1", link.getAddress());
|
assertEquals("'Hyperlinks'!A1", link.getAddress());
|
||||||
|
|
||||||
wbBack.close();
|
wbBack.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -208,7 +208,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink {
|
||||||
cell.setHyperlink(link);
|
cell.setHyperlink(link);
|
||||||
|
|
||||||
HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
HSSFWorkbook wbBack = HSSFTestDataSamples.writeOutAndReadBack(wb);
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
|
|
||||||
sheet = wbBack.getSheet("Hyperlinks");
|
sheet = wbBack.getSheet("Hyperlinks");
|
||||||
|
@ -217,7 +217,7 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink {
|
||||||
link = cell.getHyperlink();
|
link = cell.getHyperlink();
|
||||||
assertNotNull(link);
|
assertNotNull(link);
|
||||||
assertEquals("testfolder\\test.PDF", link.getAddress());
|
assertEquals("testfolder\\test.PDF", link.getAddress());
|
||||||
|
|
||||||
wbBack.close();
|
wbBack.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -266,12 +266,12 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink {
|
||||||
assertEquals(5, link2_shifted.getFirstRow());
|
assertEquals(5, link2_shifted.getFirstRow());
|
||||||
assertEquals(5, link2_shifted.getLastRow());
|
assertEquals(5, link2_shifted.getLastRow());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public HSSFHyperlink copyHyperlink(Hyperlink link) {
|
public HSSFHyperlink copyHyperlink(Hyperlink link) {
|
||||||
return new HSSFHyperlink(link);
|
return new HSSFHyperlink(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@Test
|
@Test
|
||||||
public void testCopyXSSFHyperlink() throws IOException {
|
public void testCopyXSSFHyperlink() throws IOException {
|
||||||
|
@ -282,12 +282,12 @@ public final class TestHSSFHyperlink extends BaseTestHyperlink {
|
||||||
xlink.setCellReference("D3");
|
xlink.setCellReference("D3");
|
||||||
xlink.setTooltip("tooltip");
|
xlink.setTooltip("tooltip");
|
||||||
HSSFHyperlink hlink = new HSSFHyperlink(xlink);
|
HSSFHyperlink hlink = new HSSFHyperlink(xlink);
|
||||||
|
|
||||||
assertEquals("http://poi.apache.org/", hlink.getAddress());
|
assertEquals("http://poi.apache.org/", hlink.getAddress());
|
||||||
assertEquals("D3", new CellReference(hlink.getFirstRow(), hlink.getFirstColumn()).formatAsString());
|
assertEquals("D3", new CellReference(hlink.getFirstRow(), hlink.getFirstColumn()).formatAsString());
|
||||||
// Are HSSFHyperlink.label and XSSFHyperlink.tooltip the same? If so, perhaps one of these needs renamed for a consistent Hyperlink interface
|
// Are HSSFHyperlink.label and XSSFHyperlink.tooltip the same? If so, perhaps one of these needs renamed for a consistent Hyperlink interface
|
||||||
// assertEquals("tooltip", hlink.getLabel());
|
// assertEquals("tooltip", hlink.getLabel());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}*/
|
}*/
|
||||||
}
|
}
|
||||||
|
|
|
@ -808,7 +808,7 @@ public abstract class BaseTestCell {
|
||||||
|
|
||||||
Cell cell3 = row.createCell(2);
|
Cell cell3 = row.createCell(2);
|
||||||
Hyperlink link3 = helper.createHyperlink(HyperlinkType.URL);
|
Hyperlink link3 = helper.createHyperlink(HyperlinkType.URL);
|
||||||
link3.setAddress("http://poi.apache.org/");
|
link3.setAddress("https://poi.apache.org/");
|
||||||
cell3.setHyperlink(link3);
|
cell3.setHyperlink(link3);
|
||||||
assertNotNull(cell3.getHyperlink());
|
assertNotNull(cell3.getHyperlink());
|
||||||
|
|
||||||
|
|
|
@ -54,7 +54,7 @@ public abstract class BaseTestHyperlink {
|
||||||
cell = sheet.createRow(0).createCell((short) 0);
|
cell = sheet.createRow(0).createCell((short) 0);
|
||||||
cell.setCellValue("URL Link");
|
cell.setCellValue("URL Link");
|
||||||
link = createHelper.createHyperlink(HyperlinkType.URL);
|
link = createHelper.createHyperlink(HyperlinkType.URL);
|
||||||
link.setAddress("http://poi.apache.org/");
|
link.setAddress("https://poi.apache.org/");
|
||||||
cell.setHyperlink(link);
|
cell.setHyperlink(link);
|
||||||
|
|
||||||
//link to a file in the current directory
|
//link to a file in the current directory
|
||||||
|
@ -90,17 +90,17 @@ public abstract class BaseTestHyperlink {
|
||||||
sheet = wb2.getSheetAt(0);
|
sheet = wb2.getSheetAt(0);
|
||||||
link = sheet.getRow(0).getCell(0).getHyperlink();
|
link = sheet.getRow(0).getCell(0).getHyperlink();
|
||||||
|
|
||||||
assertEquals("http://poi.apache.org/", link.getAddress());
|
assertEquals("https://poi.apache.org/", link.getAddress());
|
||||||
link = sheet.getRow(1).getCell(0).getHyperlink();
|
link = sheet.getRow(1).getCell(0).getHyperlink();
|
||||||
assertEquals("hyperinks-beta4-dump.txt", link.getAddress());
|
assertEquals("hyperinks-beta4-dump.txt", link.getAddress());
|
||||||
link = sheet.getRow(2).getCell(0).getHyperlink();
|
link = sheet.getRow(2).getCell(0).getHyperlink();
|
||||||
assertEquals("mailto:poi@apache.org?subject=Hyperlinks", link.getAddress());
|
assertEquals("mailto:poi@apache.org?subject=Hyperlinks", link.getAddress());
|
||||||
link = sheet.getRow(3).getCell(0).getHyperlink();
|
link = sheet.getRow(3).getCell(0).getHyperlink();
|
||||||
assertEquals("'Target Sheet'!A1", link.getAddress());
|
assertEquals("'Target Sheet'!A1", link.getAddress());
|
||||||
|
|
||||||
wb2.close();
|
wb2.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy a hyperlink via the copy constructor
|
// copy a hyperlink via the copy constructor
|
||||||
@Test
|
@Test
|
||||||
public void testCopyHyperlink() throws IOException {
|
public void testCopyHyperlink() throws IOException {
|
||||||
|
@ -117,32 +117,32 @@ public abstract class BaseTestHyperlink {
|
||||||
cell2 = row.createCell(1);
|
cell2 = row.createCell(1);
|
||||||
cell1.setCellValue("URL Link");
|
cell1.setCellValue("URL Link");
|
||||||
link1 = createHelper.createHyperlink(HyperlinkType.URL);
|
link1 = createHelper.createHyperlink(HyperlinkType.URL);
|
||||||
link1.setAddress("http://poi.apache.org/");
|
link1.setAddress("https://poi.apache.org/");
|
||||||
cell1.setHyperlink(link1);
|
cell1.setHyperlink(link1);
|
||||||
|
|
||||||
link2 = copyHyperlink(link1);
|
link2 = copyHyperlink(link1);
|
||||||
|
|
||||||
// Change address (type is not changeable)
|
// Change address (type is not changeable)
|
||||||
link2.setAddress("http://apache.org/");
|
link2.setAddress("http://apache.org/");
|
||||||
cell2.setHyperlink(link2);
|
cell2.setHyperlink(link2);
|
||||||
|
|
||||||
// Make sure hyperlinks were deep-copied, and modifying one does not modify the other.
|
// Make sure hyperlinks were deep-copied, and modifying one does not modify the other.
|
||||||
assertNotSame(link1, link2);
|
assertNotSame(link1, link2);
|
||||||
assertNotEquals(link1, link2);
|
assertNotEquals(link1, link2);
|
||||||
assertEquals("http://poi.apache.org/", link1.getAddress());
|
assertEquals("https://poi.apache.org/", link1.getAddress());
|
||||||
assertEquals("http://apache.org/", link2.getAddress());
|
assertEquals("http://apache.org/", link2.getAddress());
|
||||||
assertEquals(link1, cell1.getHyperlink());
|
assertEquals(link1, cell1.getHyperlink());
|
||||||
assertEquals(link2, cell2.getHyperlink());
|
assertEquals(link2, cell2.getHyperlink());
|
||||||
|
|
||||||
// Make sure both hyperlinks were added to the sheet
|
// Make sure both hyperlinks were added to the sheet
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
final List<Hyperlink> actualHyperlinks = (List<Hyperlink>) sheet.getHyperlinkList();
|
final List<Hyperlink> actualHyperlinks = (List<Hyperlink>) sheet.getHyperlinkList();
|
||||||
assertEquals(2, actualHyperlinks.size());
|
assertEquals(2, actualHyperlinks.size());
|
||||||
assertEquals(link1, actualHyperlinks.get(0));
|
assertEquals(link1, actualHyperlinks.get(0));
|
||||||
assertEquals(link2, actualHyperlinks.get(1));
|
assertEquals(link2, actualHyperlinks.get(1));
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract Hyperlink copyHyperlink(Hyperlink link);
|
public abstract Hyperlink copyHyperlink(Hyperlink link);
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,18 +74,18 @@ public abstract class BaseTestSheetShiftColumns {
|
||||||
textCell.setCellValue("TEXT");
|
textCell.setCellValue("TEXT");
|
||||||
textCell.setCellStyle(newCenterBottomStyle());
|
textCell.setCellStyle(newCenterBottomStyle());
|
||||||
|
|
||||||
sheet2 = workbook.createSheet("sheet2");
|
sheet2 = workbook.createSheet("sheet2");
|
||||||
row = sheet2.createRow(0); row.createCell(0, CellType.NUMERIC).setCellValue(10);
|
row = sheet2.createRow(0); row.createCell(0, CellType.NUMERIC).setCellValue(10);
|
||||||
row.createCell(1, CellType.NUMERIC).setCellValue(11);
|
row.createCell(1, CellType.NUMERIC).setCellValue(11);
|
||||||
row.createCell(2, CellType.FORMULA).setCellFormula("SUM(sheet1!B3:C3)");
|
row.createCell(2, CellType.FORMULA).setCellFormula("SUM(sheet1!B3:C3)");
|
||||||
row = sheet2.createRow(1);
|
row = sheet2.createRow(1);
|
||||||
row.createCell(0, CellType.NUMERIC).setCellValue(21);
|
row.createCell(0, CellType.NUMERIC).setCellValue(21);
|
||||||
row.createCell(1, CellType.NUMERIC).setCellValue(22);
|
row.createCell(1, CellType.NUMERIC).setCellValue(22);
|
||||||
row.createCell(2, CellType.NUMERIC).setCellValue(23);
|
row.createCell(2, CellType.NUMERIC).setCellValue(23);
|
||||||
row = sheet2.createRow(2);
|
row = sheet2.createRow(2);
|
||||||
row.createCell(0, CellType.FORMULA).setCellFormula("sheet1!A4+sheet1!C2+A2");
|
row.createCell(0, CellType.FORMULA).setCellFormula("sheet1!A4+sheet1!C2+A2");
|
||||||
row.createCell(1, CellType.FORMULA).setCellFormula("SUM(sheet1!A3:$C3)");
|
row.createCell(1, CellType.FORMULA).setCellFormula("SUM(sheet1!A3:$C3)");
|
||||||
row = sheet2.createRow(3);
|
row = sheet2.createRow(3);
|
||||||
row.createCell(0, CellType.STRING).setCellValue("dummy");
|
row.createCell(0, CellType.STRING).setCellValue("dummy");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -116,7 +116,7 @@ public abstract class BaseTestSheetShiftColumns {
|
||||||
Cell textCell = sheet1.getRow(6).getCell(3);
|
Cell textCell = sheet1.getRow(6).getCell(3);
|
||||||
assertEquals(textCell.getStringCellValue(), "TEXT");
|
assertEquals(textCell.getStringCellValue(), "TEXT");
|
||||||
assertEquals(textCell.getCellStyle().getAlignment(), HorizontalAlignment.CENTER);
|
assertEquals(textCell.getCellStyle().getAlignment(), HorizontalAlignment.CENTER);
|
||||||
|
|
||||||
// other sheet
|
// other sheet
|
||||||
String formulaC1 = sheet2.getRow(0).getCell(2).getCellFormula(); // SUM(sheet1!B3:C3)
|
String formulaC1 = sheet2.getRow(0).getCell(2).getCellFormula(); // SUM(sheet1!B3:C3)
|
||||||
assertEquals("SUM(sheet1!C3:D3)", formulaC1);
|
assertEquals("SUM(sheet1!C3:D3)", formulaC1);
|
||||||
|
@ -155,7 +155,7 @@ public abstract class BaseTestSheetShiftColumns {
|
||||||
Cell newb6Null = sheet1.getRow(5).getCell(1);
|
Cell newb6Null = sheet1.getRow(5).getCell(1);
|
||||||
assertNull(newb6Null);
|
assertNull(newb6Null);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test(expected = IllegalStateException.class)
|
@Test(expected = IllegalStateException.class)
|
||||||
public void testShiftTwoColumnsLeft() {
|
public void testShiftTwoColumnsLeft() {
|
||||||
sheet1.shiftColumns(1, 2, -2);
|
sheet1.shiftColumns(1, 2, -2);
|
||||||
|
@ -186,7 +186,7 @@ public abstract class BaseTestSheetShiftColumns {
|
||||||
cell = row.createCell(1);
|
cell = row.createCell(1);
|
||||||
// CellAddress=B1, shifted to B4
|
// CellAddress=B1, shifted to B4
|
||||||
cell.setCellStyle(hlinkStyle);
|
cell.setCellStyle(hlinkStyle);
|
||||||
createHyperlink(helper, cell, HyperlinkType.URL, "http://poi.apache.org/");
|
createHyperlink(helper, cell, HyperlinkType.URL, "https://poi.apache.org/");
|
||||||
|
|
||||||
// row0 will be shifted on top of row1, so this URL should be removed
|
// row0 will be shifted on top of row1, so this URL should be removed
|
||||||
// from the workbook
|
// from the workbook
|
||||||
|
@ -225,7 +225,7 @@ public abstract class BaseTestSheetShiftColumns {
|
||||||
verifyHyperlink(shiftedRow.getCell(3), HyperlinkType.DOCUMENT, "test!E1");
|
verifyHyperlink(shiftedRow.getCell(3), HyperlinkType.DOCUMENT, "test!E1");
|
||||||
|
|
||||||
// URL, EMAIL, and FILE links anchored on a shifted cell should be moved
|
// URL, EMAIL, and FILE links anchored on a shifted cell should be moved
|
||||||
verifyHyperlink(shiftedRow.getCell(4), HyperlinkType.URL, "http://poi.apache.org/");
|
verifyHyperlink(shiftedRow.getCell(4), HyperlinkType.URL, "https://poi.apache.org/");
|
||||||
|
|
||||||
// Make sure hyperlinks were moved and not copied
|
// Make sure hyperlinks were moved and not copied
|
||||||
assertNull("Document hyperlink should be moved, not copied", sh.getHyperlink(0, 0));
|
assertNull("Document hyperlink should be moved, not copied", sh.getHyperlink(0, 0));
|
||||||
|
@ -331,7 +331,7 @@ public abstract class BaseTestSheetShiftColumns {
|
||||||
|
|
||||||
protected abstract Workbook openWorkbook(String spreadsheetFileName) throws IOException;
|
protected abstract Workbook openWorkbook(String spreadsheetFileName) throws IOException;
|
||||||
protected abstract Workbook getReadBackWorkbook(Workbook wb) throws IOException;
|
protected abstract Workbook getReadBackWorkbook(Workbook wb) throws IOException;
|
||||||
|
|
||||||
protected static final String AMDOCS = "Amdocs";
|
protected static final String AMDOCS = "Amdocs";
|
||||||
protected static final String AMDOCS_TEST = "Amdocs:\ntest\n";
|
protected static final String AMDOCS_TEST = "Amdocs:\ntest\n";
|
||||||
|
|
||||||
|
@ -344,7 +344,7 @@ public abstract class BaseTestSheetShiftColumns {
|
||||||
assertNotNull(comment);
|
assertNotNull(comment);
|
||||||
assertEquals(AMDOCS, comment.getAuthor());
|
assertEquals(AMDOCS, comment.getAuthor());
|
||||||
assertEquals(AMDOCS_TEST, comment.getString().getString());
|
assertEquals(AMDOCS_TEST, comment.getString().getString());
|
||||||
|
|
||||||
sheet.shiftColumns(0, 1, 1);
|
sheet.shiftColumns(0, 1, 1);
|
||||||
|
|
||||||
// comment in column 0 is gone
|
// comment in column 0 is gone
|
||||||
|
@ -374,19 +374,19 @@ public abstract class BaseTestSheetShiftColumns {
|
||||||
assertEquals(AMDOCS_TEST, comment.getString().getString());
|
assertEquals(AMDOCS_TEST, comment.getString().getString());
|
||||||
wbBack.close();
|
wbBack.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
// transposed version of TestXSSFSheetShiftRows.testBug54524()
|
// transposed version of TestXSSFSheetShiftRows.testBug54524()
|
||||||
@Test
|
@Test
|
||||||
public void testBug54524() throws IOException {
|
public void testBug54524() throws IOException {
|
||||||
Workbook wb = _testDataProvider.createWorkbook();
|
Workbook wb = _testDataProvider.createWorkbook();
|
||||||
Sheet sheet = wb.createSheet();
|
Sheet sheet = wb.createSheet();
|
||||||
Row firstRow = sheet.createRow(0);
|
Row firstRow = sheet.createRow(0);
|
||||||
firstRow.createCell(0).setCellValue("");
|
firstRow.createCell(0).setCellValue("");
|
||||||
firstRow.createCell(1).setCellValue(1);
|
firstRow.createCell(1).setCellValue(1);
|
||||||
firstRow.createCell(2).setCellValue(2);
|
firstRow.createCell(2).setCellValue(2);
|
||||||
firstRow.createCell(3).setCellFormula("SUM(B1:C1)");
|
firstRow.createCell(3).setCellFormula("SUM(B1:C1)");
|
||||||
firstRow.createCell(4).setCellValue("X");
|
firstRow.createCell(4).setCellValue("X");
|
||||||
|
|
||||||
sheet.shiftColumns(3, 5, -1);
|
sheet.shiftColumns(3, 5, -1);
|
||||||
|
|
||||||
Cell cell = CellUtil.getCell(sheet.getRow(0), 1);
|
Cell cell = CellUtil.getCell(sheet.getRow(0), 1);
|
||||||
|
|
|
@ -97,7 +97,7 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
assertEquals(s.getRow(5).getPhysicalNumberOfCells(), 2);
|
assertEquals(s.getRow(5).getPhysicalNumberOfCells(), 2);
|
||||||
|
|
||||||
wb3.close();
|
wb3.close();
|
||||||
|
|
||||||
// Read the first file again
|
// Read the first file again
|
||||||
Workbook wb4 = _testDataProvider.openSampleWorkbook(sampleName);
|
Workbook wb4 = _testDataProvider.openSampleWorkbook(sampleName);
|
||||||
s = wb4.getSheetAt( 0 );
|
s = wb4.getSheetAt( 0 );
|
||||||
|
@ -192,7 +192,7 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
// Ensure that the changes were persisted
|
// Ensure that the changes were persisted
|
||||||
Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
|
Workbook wb2 = _testDataProvider.writeOutAndReadBack(wb1);
|
||||||
wb1.close();
|
wb1.close();
|
||||||
|
|
||||||
sheet = wb2.getSheet("Sheet1");
|
sheet = wb2.getSheet("Sheet1");
|
||||||
assertEquals(4, sheet.getLastRowNum());
|
assertEquals(4, sheet.getLastRowNum());
|
||||||
|
|
||||||
|
@ -217,7 +217,7 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
// by shifting rows...
|
// by shifting rows...
|
||||||
if(!(wb2 instanceof HSSFWorkbook)) {
|
if(!(wb2 instanceof HSSFWorkbook)) {
|
||||||
assertEquals(2, sheet.getLastRowNum());
|
assertEquals(2, sheet.getLastRowNum());
|
||||||
|
|
||||||
// Verify comments are in the position expected
|
// Verify comments are in the position expected
|
||||||
assertNull("Had: " + (sheet.getCellComment(new CellAddress(0,0)) == null ? "null" : sheet.getCellComment(new CellAddress(0,0)).getString()),
|
assertNull("Had: " + (sheet.getCellComment(new CellAddress(0,0)) == null ? "null" : sheet.getCellComment(new CellAddress(0,0)).getString()),
|
||||||
sheet.getCellComment(new CellAddress(0,0)));
|
sheet.getCellComment(new CellAddress(0,0)));
|
||||||
|
@ -229,7 +229,7 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
assertEquals(comment1,"comment top row3 (index2)\n");
|
assertEquals(comment1,"comment top row3 (index2)\n");
|
||||||
String comment2 = sheet.getCellComment(new CellAddress(2,0)).getString().getString();
|
String comment2 = sheet.getCellComment(new CellAddress(2,0)).getString().getString();
|
||||||
assertEquals(comment2,"comment top row4 (index3)\n");
|
assertEquals(comment2,"comment top row4 (index3)\n");
|
||||||
|
|
||||||
wb2.close();
|
wb2.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -274,7 +274,7 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
|
|
||||||
name4 = wb.getName("name4");
|
name4 = wb.getName("name4");
|
||||||
assertEquals("A1", name4.getRefersToFormula());
|
assertEquals("A1", name4.getRefersToFormula());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,31 +304,31 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
// populate sheet cells
|
// populate sheet cells
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
Row row = sheet.createRow(i);
|
Row row = sheet.createRow(i);
|
||||||
|
|
||||||
for (int j = 0; j < 10; j++) {
|
for (int j = 0; j < 10; j++) {
|
||||||
Cell cell = row.createCell(j, CellType.STRING);
|
Cell cell = row.createCell(j, CellType.STRING);
|
||||||
cell.setCellValue(i + "x" + j);
|
cell.setCellValue(i + "x" + j);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CellRangeAddress A4_B7 = CellRangeAddress.valueOf("A4:B7");
|
CellRangeAddress A4_B7 = CellRangeAddress.valueOf("A4:B7");
|
||||||
CellRangeAddress C4_D7 = CellRangeAddress.valueOf("C4:D7");
|
CellRangeAddress C4_D7 = CellRangeAddress.valueOf("C4:D7");
|
||||||
|
|
||||||
assertEquals(0, sheet.addMergedRegion(A4_B7));
|
assertEquals(0, sheet.addMergedRegion(A4_B7));
|
||||||
assertEquals(1, sheet.addMergedRegion(C4_D7));
|
assertEquals(1, sheet.addMergedRegion(C4_D7));
|
||||||
|
|
||||||
assumeTrue(sheet.getLastRowNum() > 8);
|
assumeTrue(sheet.getLastRowNum() > 8);
|
||||||
|
|
||||||
// Insert a row in the middle of both merged regions.
|
// Insert a row in the middle of both merged regions.
|
||||||
sheet.shiftRows(4, sheet.getLastRowNum(), 1);
|
sheet.shiftRows(4, sheet.getLastRowNum(), 1);
|
||||||
|
|
||||||
// all regions should still start at row 3, and elongate by 1 row
|
// all regions should still start at row 3, and elongate by 1 row
|
||||||
List<CellRangeAddress> expectedMergedRegions = new ArrayList<>();
|
List<CellRangeAddress> expectedMergedRegions = new ArrayList<>();
|
||||||
CellRangeAddress A4_B8 = CellRangeAddress.valueOf("A4:B8"); //A4:B7 should be elongated by 1 row
|
CellRangeAddress A4_B8 = CellRangeAddress.valueOf("A4:B8"); //A4:B7 should be elongated by 1 row
|
||||||
CellRangeAddress C4_D8 = CellRangeAddress.valueOf("C4:D8"); //C4:B7 should be elongated by 1 row
|
CellRangeAddress C4_D8 = CellRangeAddress.valueOf("C4:D8"); //C4:B7 should be elongated by 1 row
|
||||||
expectedMergedRegions.add(A4_B8);
|
expectedMergedRegions.add(A4_B8);
|
||||||
expectedMergedRegions.add(C4_D8);
|
expectedMergedRegions.add(C4_D8);
|
||||||
|
|
||||||
// This test is written as expected-to-fail and should be rewritten
|
// This test is written as expected-to-fail and should be rewritten
|
||||||
// as expected-to-pass when the bug is fixed.
|
// as expected-to-pass when the bug is fixed.
|
||||||
// FIXME: remove try, catch, and testPassesNow, skipTest when test passes
|
// FIXME: remove try, catch, and testPassesNow, skipTest when test passes
|
||||||
|
@ -340,8 +340,8 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
}
|
}
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See bug #34023
|
* See bug #34023
|
||||||
|
@ -498,7 +498,7 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unified test for:
|
* Unified test for:
|
||||||
* bug 46742: XSSFSheet.shiftRows should shift hyperlinks
|
* bug 46742: XSSFSheet.shiftRows should shift hyperlinks
|
||||||
|
@ -509,7 +509,7 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
Workbook wb = _testDataProvider.createWorkbook();
|
Workbook wb = _testDataProvider.createWorkbook();
|
||||||
Sheet sheet = wb.createSheet("test");
|
Sheet sheet = wb.createSheet("test");
|
||||||
Row row = sheet.createRow(0);
|
Row row = sheet.createRow(0);
|
||||||
|
|
||||||
// How to create hyperlinks
|
// How to create hyperlinks
|
||||||
// https://poi.apache.org/spreadsheet/quick-guide.html#Hyperlinks
|
// https://poi.apache.org/spreadsheet/quick-guide.html#Hyperlinks
|
||||||
CreationHelper helper = wb.getCreationHelper();
|
CreationHelper helper = wb.getCreationHelper();
|
||||||
|
@ -524,55 +524,55 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
Cell cell = row.createCell(0);
|
Cell cell = row.createCell(0);
|
||||||
cell.setCellStyle(hlinkStyle);
|
cell.setCellStyle(hlinkStyle);
|
||||||
createHyperlink(helper, cell, HyperlinkType.DOCUMENT, "test!E1");
|
createHyperlink(helper, cell, HyperlinkType.DOCUMENT, "test!E1");
|
||||||
|
|
||||||
// URL
|
// URL
|
||||||
cell = row.createCell(1);
|
cell = row.createCell(1);
|
||||||
// CellAddress=B1, shifted to B4
|
// CellAddress=B1, shifted to B4
|
||||||
cell.setCellStyle(hlinkStyle);
|
cell.setCellStyle(hlinkStyle);
|
||||||
createHyperlink(helper, cell, HyperlinkType.URL, "http://poi.apache.org/");
|
createHyperlink(helper, cell, HyperlinkType.URL, "https://poi.apache.org/");
|
||||||
|
|
||||||
// row0 will be shifted on top of row1, so this URL should be removed from the workbook
|
// row0 will be shifted on top of row1, so this URL should be removed from the workbook
|
||||||
Row overwrittenRow = sheet.createRow(3);
|
Row overwrittenRow = sheet.createRow(3);
|
||||||
cell = overwrittenRow.createCell(2);
|
cell = overwrittenRow.createCell(2);
|
||||||
// CellAddress=C4, will be overwritten (deleted)
|
// CellAddress=C4, will be overwritten (deleted)
|
||||||
cell.setCellStyle(hlinkStyle);
|
cell.setCellStyle(hlinkStyle);
|
||||||
createHyperlink(helper, cell, HyperlinkType.EMAIL, "mailto:poi@apache.org");
|
createHyperlink(helper, cell, HyperlinkType.EMAIL, "mailto:poi@apache.org");
|
||||||
|
|
||||||
// hyperlinks on this row are unaffected by the row shifting, so the hyperlinks should not move
|
// hyperlinks on this row are unaffected by the row shifting, so the hyperlinks should not move
|
||||||
Row unaffectedRow = sheet.createRow(20);
|
Row unaffectedRow = sheet.createRow(20);
|
||||||
cell = unaffectedRow.createCell(3);
|
cell = unaffectedRow.createCell(3);
|
||||||
// CellAddress=D21, will be unaffected
|
// CellAddress=D21, will be unaffected
|
||||||
cell.setCellStyle(hlinkStyle);
|
cell.setCellStyle(hlinkStyle);
|
||||||
createHyperlink(helper, cell, HyperlinkType.FILE, "54524.xlsx");
|
createHyperlink(helper, cell, HyperlinkType.FILE, "54524.xlsx");
|
||||||
|
|
||||||
cell = wb.createSheet("other").createRow(0).createCell(0);
|
cell = wb.createSheet("other").createRow(0).createCell(0);
|
||||||
// CellAddress=Other!A1, will be unaffected
|
// CellAddress=Other!A1, will be unaffected
|
||||||
cell.setCellStyle(hlinkStyle);
|
cell.setCellStyle(hlinkStyle);
|
||||||
createHyperlink(helper, cell, HyperlinkType.URL, "http://apache.org/");
|
createHyperlink(helper, cell, HyperlinkType.URL, "http://apache.org/");
|
||||||
|
|
||||||
int startRow = 0;
|
int startRow = 0;
|
||||||
int endRow = 0;
|
int endRow = 0;
|
||||||
int n = 3;
|
int n = 3;
|
||||||
sheet.shiftRows(startRow, endRow, n);
|
sheet.shiftRows(startRow, endRow, n);
|
||||||
|
|
||||||
Workbook read = _testDataProvider.writeOutAndReadBack(wb);
|
Workbook read = _testDataProvider.writeOutAndReadBack(wb);
|
||||||
wb.close();
|
wb.close();
|
||||||
|
|
||||||
Sheet sh = read.getSheet("test");
|
Sheet sh = read.getSheet("test");
|
||||||
|
|
||||||
Row shiftedRow = sh.getRow(3);
|
Row shiftedRow = sh.getRow(3);
|
||||||
|
|
||||||
// document link anchored on a shifted cell should be moved
|
// document link anchored on a shifted cell should be moved
|
||||||
// Note that hyperlinks do not track what they point to, so this hyperlink should still refer to test!E1
|
// Note that hyperlinks do not track what they point to, so this hyperlink should still refer to test!E1
|
||||||
verifyHyperlink(shiftedRow.getCell(0), HyperlinkType.DOCUMENT, "test!E1");
|
verifyHyperlink(shiftedRow.getCell(0), HyperlinkType.DOCUMENT, "test!E1");
|
||||||
|
|
||||||
// URL, EMAIL, and FILE links anchored on a shifted cell should be moved
|
// URL, EMAIL, and FILE links anchored on a shifted cell should be moved
|
||||||
verifyHyperlink(shiftedRow.getCell(1), HyperlinkType.URL, "http://poi.apache.org/");
|
verifyHyperlink(shiftedRow.getCell(1), HyperlinkType.URL, "https://poi.apache.org/");
|
||||||
|
|
||||||
// Make sure hyperlinks were moved and not copied
|
// Make sure hyperlinks were moved and not copied
|
||||||
assertNull("Document hyperlink should be moved, not copied", sh.getHyperlink(0, 0));
|
assertNull("Document hyperlink should be moved, not copied", sh.getHyperlink(0, 0));
|
||||||
assertNull("URL hyperlink should be moved, not copied", sh.getHyperlink(0, 1));
|
assertNull("URL hyperlink should be moved, not copied", sh.getHyperlink(0, 1));
|
||||||
|
|
||||||
// Make sure hyperlink in overwritten row is deleted
|
// Make sure hyperlink in overwritten row is deleted
|
||||||
assertEquals(3, sh.getHyperlinkList().size());
|
assertEquals(3, sh.getHyperlinkList().size());
|
||||||
CellAddress unexpectedLinkAddress = new CellAddress("C4");
|
CellAddress unexpectedLinkAddress = new CellAddress("C4");
|
||||||
|
@ -583,26 +583,26 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
"been deleted when Row 1 was shifted on top of it.");
|
"been deleted when Row 1 was shifted on top of it.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Make sure unaffected rows are not shifted
|
// Make sure unaffected rows are not shifted
|
||||||
Cell unaffectedCell = sh.getRow(20).getCell(3);
|
Cell unaffectedCell = sh.getRow(20).getCell(3);
|
||||||
assertTrue(cellHasHyperlink(unaffectedCell));
|
assertTrue(cellHasHyperlink(unaffectedCell));
|
||||||
verifyHyperlink(unaffectedCell, HyperlinkType.FILE, "54524.xlsx");
|
verifyHyperlink(unaffectedCell, HyperlinkType.FILE, "54524.xlsx");
|
||||||
|
|
||||||
// Make sure cells on other sheets are not affected
|
// Make sure cells on other sheets are not affected
|
||||||
unaffectedCell = read.getSheet("other").getRow(0).getCell(0);
|
unaffectedCell = read.getSheet("other").getRow(0).getCell(0);
|
||||||
assertTrue(cellHasHyperlink(unaffectedCell));
|
assertTrue(cellHasHyperlink(unaffectedCell));
|
||||||
verifyHyperlink(unaffectedCell, HyperlinkType.URL, "http://apache.org/");
|
verifyHyperlink(unaffectedCell, HyperlinkType.URL, "http://apache.org/");
|
||||||
|
|
||||||
read.close();
|
read.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
//@Ignore("bug 56454: Incorrectly handles merged regions that do not contain column 0")
|
//@Ignore("bug 56454: Incorrectly handles merged regions that do not contain column 0")
|
||||||
@Test
|
@Test
|
||||||
public void shiftRowsWithMergedRegionsThatDoNotContainColumnZero() throws IOException {
|
public void shiftRowsWithMergedRegionsThatDoNotContainColumnZero() throws IOException {
|
||||||
Workbook wb = _testDataProvider.createWorkbook();
|
Workbook wb = _testDataProvider.createWorkbook();
|
||||||
Sheet sheet = wb.createSheet("test");
|
Sheet sheet = wb.createSheet("test");
|
||||||
|
|
||||||
// populate sheet cells
|
// populate sheet cells
|
||||||
for (int i = 0; i < 10; i++) {
|
for (int i = 0; i < 10; i++) {
|
||||||
Row row = sheet.createRow(i);
|
Row row = sheet.createRow(i);
|
||||||
|
@ -633,7 +633,7 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
} catch (AssertionError e) {
|
} catch (AssertionError e) {
|
||||||
skipTest(e);
|
skipTest(e);
|
||||||
}
|
}
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -740,32 +740,32 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test61840_shifting_rows_up_does_not_produce_REF_errors() throws IOException {
|
public void test61840_shifting_rows_up_does_not_produce_REF_errors() throws IOException {
|
||||||
Workbook wb = _testDataProvider.createWorkbook();
|
Workbook wb = _testDataProvider.createWorkbook();
|
||||||
Sheet sheet = wb.createSheet();
|
Sheet sheet = wb.createSheet();
|
||||||
Cell cell = sheet.createRow(4).createCell(0);
|
Cell cell = sheet.createRow(4).createCell(0);
|
||||||
|
|
||||||
cell.setCellFormula("(B5-C5)/B5");
|
cell.setCellFormula("(B5-C5)/B5");
|
||||||
sheet.shiftRows(4, 4, -1);
|
sheet.shiftRows(4, 4, -1);
|
||||||
|
|
||||||
// Cell objects created before a row shift are still valid.
|
// Cell objects created before a row shift are still valid.
|
||||||
// The row number of those cell references will be shifted if
|
// The row number of those cell references will be shifted if
|
||||||
// the cell is within the shift range.
|
// the cell is within the shift range.
|
||||||
assertEquals("(B4-C4)/B4", cell.getCellFormula());
|
assertEquals("(B4-C4)/B4", cell.getCellFormula());
|
||||||
|
|
||||||
// New cell references are also valid.
|
// New cell references are also valid.
|
||||||
Cell shiftedCell = sheet.getRow(3).getCell(0);
|
Cell shiftedCell = sheet.getRow(3).getCell(0);
|
||||||
assertNotNull(shiftedCell);
|
assertNotNull(shiftedCell);
|
||||||
assertEquals("(B4-C4)/B4", shiftedCell.getCellFormula());
|
assertEquals("(B4-C4)/B4", shiftedCell.getCellFormula());
|
||||||
|
|
||||||
wb.close();
|
wb.close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
private void createHyperlink(CreationHelper helper, Cell cell, HyperlinkType linkType, String ref) {
|
private void createHyperlink(CreationHelper helper, Cell cell, HyperlinkType linkType, String ref) {
|
||||||
cell.setCellValue(ref);
|
cell.setCellValue(ref);
|
||||||
|
@ -773,14 +773,14 @@ public abstract class BaseTestSheetShiftRows {
|
||||||
link.setAddress(ref);
|
link.setAddress(ref);
|
||||||
cell.setHyperlink(link);
|
cell.setHyperlink(link);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void verifyHyperlink(Cell cell, HyperlinkType linkType, String ref) {
|
private void verifyHyperlink(Cell cell, HyperlinkType linkType, String ref) {
|
||||||
assertTrue(cellHasHyperlink(cell));
|
assertTrue(cellHasHyperlink(cell));
|
||||||
Hyperlink link = cell.getHyperlink();
|
Hyperlink link = cell.getHyperlink();
|
||||||
assertEquals(linkType, link.getType());
|
assertEquals(linkType, link.getType());
|
||||||
assertEquals(ref, link.getAddress());
|
assertEquals(ref, link.getAddress());
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean cellHasHyperlink(Cell cell) {
|
private boolean cellHasHyperlink(Cell cell) {
|
||||||
return (cell != null) && (cell.getHyperlink() != null);
|
return (cell != null) && (cell.getHyperlink() != null);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue