本文整理匯總了Java中org.apache.poi.ss.usermodel.Cell.setHyperlink方法的典型用法代碼示例。如果您正苦於以下問題:Java Cell.setHyperlink方法的具體用法?Java Cell.setHyperlink怎麽用?Java Cell.setHyperlink使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.apache.poi.ss.usermodel.Cell
的用法示例。
在下文中一共展示了Cell.setHyperlink方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: setHyperlink
import org.apache.poi.ss.usermodel.Cell; //導入方法依賴的package包/類
/** 設置超鏈接屬性
* @param cell
* @param processor
* @param returnVal
* @param current
*/
private static void setHyperlink(Cell cell, LinkProcessor processor, Object returnVal, Object current) {
int linkType = 0 ;
String prefix = "";
switch (processor.getLinkType()) {
case Url:
linkType = Hyperlink.LINK_URL;
prefix = "http";
break;
case Document:
linkType = Hyperlink.LINK_DOCUMENT;
break;
case Email:
linkType = Hyperlink.LINK_EMAIL;
prefix = "mailto:";
break;
case File:
linkType = Hyperlink.LINK_FILE;
break;
}
CreationHelper creationHelper = cell.getSheet().getWorkbook().getCreationHelper();
org.apache.poi.ss.usermodel.Hyperlink hyperlink = creationHelper.createHyperlink(linkType);
String address = processor.getLinkAddress(returnVal, current);
if(!address.startsWith(prefix)){
if(linkType == Hyperlink.LINK_EMAIL){
address = prefix + address;
}else{
address = "http://" + address;
}
}
hyperlink.setAddress(address);
cell.setHyperlink(hyperlink);
}