aboutsummaryrefslogtreecommitdiffstats
path: root/src/examples
diff options
context:
space:
mode:
authorJaven O'Neal <onealj@apache.org>2016-07-17 09:20:21 +0000
committerJaven O'Neal <onealj@apache.org>2016-07-17 09:20:21 +0000
commit9816a7ccd8578d31ea4ce62af2457951ed71b399 (patch)
tree06ec3b9e3c5eb124f7d95a7a6b49920e8f0a0746 /src/examples
parentfe46099398636324c2fc79aea16bdd2469aacf20 (diff)
downloadpoi-9816a7ccd8578d31ea4ce62af2457951ed71b399.tar.gz
poi-9816a7ccd8578d31ea4ce62af2457951ed71b399.zip
bug 59873: replace Hyperlink.LINK_* int constants with HyperlinkType enum
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1753035 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/examples')
-rw-r--r--src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java24
1 files changed, 16 insertions, 8 deletions
diff --git a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java b/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java
index 0872749d02..c1ccad9100 100644
--- a/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java
+++ b/src/examples/src/org/apache/poi/hssf/usermodel/examples/Hyperlinks.java
@@ -17,11 +17,18 @@
package org.apache.poi.hssf.usermodel.examples;
-import org.apache.poi.hssf.usermodel.*;
-import org.apache.poi.hssf.util.HSSFColor;
-
-import java.io.IOException;
import java.io.FileOutputStream;
+import java.io.IOException;
+
+import org.apache.poi.common.usermodel.HyperlinkType;
+import org.apache.poi.hssf.usermodel.HSSFCell;
+import org.apache.poi.hssf.usermodel.HSSFCellStyle;
+import org.apache.poi.hssf.usermodel.HSSFCreationHelper;
+import org.apache.poi.hssf.usermodel.HSSFFont;
+import org.apache.poi.hssf.usermodel.HSSFHyperlink;
+import org.apache.poi.hssf.usermodel.HSSFSheet;
+import org.apache.poi.hssf.usermodel.HSSFWorkbook;
+import org.apache.poi.hssf.util.HSSFColor;
/**
* Demonstrates how to create hyperlinks.
@@ -32,6 +39,7 @@ public class Hyperlinks {
public static void main(String[] args) throws IOException {
HSSFWorkbook wb = new HSSFWorkbook();
+ HSSFCreationHelper helper = wb.getCreationHelper();
//cell style for hyperlinks
//by default hyperlinks are blue and underlined
@@ -47,7 +55,7 @@ public class Hyperlinks {
//URL
cell = sheet.createRow(0).createCell(0);
cell.setCellValue("URL Link");
- HSSFHyperlink link = new HSSFHyperlink(HSSFHyperlink.LINK_URL);
+ HSSFHyperlink link = helper.createHyperlink(HyperlinkType.URL);
link.setAddress("http://poi.apache.org/");
cell.setHyperlink(link);
cell.setCellStyle(hlink_style);
@@ -55,7 +63,7 @@ public class Hyperlinks {
//link to a file in the current directory
cell = sheet.createRow(1).createCell(0);
cell.setCellValue("File Link");
- link = new HSSFHyperlink(HSSFHyperlink.LINK_FILE);
+ link = helper.createHyperlink(HyperlinkType.FILE);
link.setAddress("link1.xls");
cell.setHyperlink(link);
cell.setCellStyle(hlink_style);
@@ -63,7 +71,7 @@ public class Hyperlinks {
//e-mail link
cell = sheet.createRow(2).createCell(0);
cell.setCellValue("Email Link");
- link = new HSSFHyperlink(HSSFHyperlink.LINK_EMAIL);
+ link = helper.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);
@@ -77,7 +85,7 @@ public class Hyperlinks {
cell = sheet.createRow(3).createCell(0);
cell.setCellValue("Worksheet Link");
- link = new HSSFHyperlink(HSSFHyperlink.LINK_DOCUMENT);
+ link = helper.createHyperlink(HyperlinkType.DOCUMENT);
link.setAddress("'Target Sheet'!A1");
cell.setHyperlink(link);
cell.setCellStyle(hlink_style);