diff options
author | Javen O'Neal <onealj@apache.org> | 2016-07-17 09:42:13 +0000 |
---|---|---|
committer | Javen O'Neal <onealj@apache.org> | 2016-07-17 09:42:13 +0000 |
commit | e9d5694574692c423c64d3864378c980cf9f86ca (patch) | |
tree | 6024d8edbc91ead27a8dc55e03286438211c4264 /src/examples | |
parent | ed944416dac5c75a82476322ba75f27cf134604e (diff) | |
download | poi-e9d5694574692c423c64d3864378c980cf9f86ca.tar.gz poi-e9d5694574692c423c64d3864378c980cf9f86ca.zip |
bug 59783: replace deprecated Hyperlink.LINK_* and Hyperlink.getType usage
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753041 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/examples')
-rw-r--r-- | src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java b/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java index 005bdc756d..e4a72fcc00 100644 --- a/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java +++ b/src/examples/src/org/apache/poi/xssf/usermodel/examples/HyperlinkExample.java @@ -18,9 +18,16 @@ package org.apache.poi.xssf.usermodel.examples; import java.io.FileOutputStream; -import org.apache.poi.ss.usermodel.*; -import org.apache.poi.xssf.usermodel.XSSFWorkbook; +import org.apache.poi.common.usermodel.HyperlinkType; +import org.apache.poi.ss.usermodel.Cell; +import org.apache.poi.ss.usermodel.CellStyle; +import org.apache.poi.ss.usermodel.CreationHelper; +import org.apache.poi.ss.usermodel.Font; +import org.apache.poi.ss.usermodel.Hyperlink; import org.apache.poi.ss.usermodel.IndexedColors; +import org.apache.poi.ss.usermodel.Sheet; +import org.apache.poi.ss.usermodel.Workbook; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; /** * Demonstrates how to create hyperlinks. @@ -43,26 +50,26 @@ public class HyperlinkExample { Cell cell; Sheet sheet = wb.createSheet("Hyperlinks"); //URL - cell = sheet.createRow(0).createCell((short)0); + cell = sheet.createRow(0).createCell(0); cell.setCellValue("URL Link"); - Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL); + Hyperlink link = createHelper.createHyperlink(HyperlinkType.URL); link.setAddress("http://poi.apache.org/"); cell.setHyperlink(link); cell.setCellStyle(hlink_style); //link to a file in the current directory - cell = sheet.createRow(1).createCell((short)0); + cell = sheet.createRow(1).createCell(0); cell.setCellValue("File Link"); - link = createHelper.createHyperlink(Hyperlink.LINK_FILE); + link = createHelper.createHyperlink(HyperlinkType.FILE); link.setAddress("link1.xls"); cell.setHyperlink(link); cell.setCellStyle(hlink_style); //e-mail link - cell = sheet.createRow(2).createCell((short)0); + cell = sheet.createRow(2).createCell(0); cell.setCellValue("Email Link"); - link = createHelper.createHyperlink(Hyperlink.LINK_EMAIL); + link = createHelper.createHyperlink(HyperlinkType.EMAIL); //note, if subject contains white spaces, make sure they are url-encoded link.setAddress("mailto:poi@apache.org?subject=Hyperlinks"); cell.setHyperlink(link); @@ -72,11 +79,11 @@ public class HyperlinkExample { //create a target sheet and cell Sheet sheet2 = wb.createSheet("Target Sheet"); - sheet2.createRow(0).createCell((short)0).setCellValue("Target Cell"); + sheet2.createRow(0).createCell(0).setCellValue("Target Cell"); - cell = sheet.createRow(3).createCell((short)0); + cell = sheet.createRow(3).createCell(0); cell.setCellValue("Worksheet Link"); - Hyperlink link2 = createHelper.createHyperlink(Hyperlink.LINK_DOCUMENT); + Hyperlink link2 = createHelper.createHyperlink(HyperlinkType.DOCUMENT); link2.setAddress("'Target Sheet'!A1"); cell.setHyperlink(link2); cell.setCellStyle(hlink_style); |