當前位置: 首頁>>代碼示例>>Java>>正文


Java Hyperlink類代碼示例

本文整理匯總了Java中org.apache.poi.common.usermodel.Hyperlink的典型用法代碼示例。如果您正苦於以下問題:Java Hyperlink類的具體用法?Java Hyperlink怎麽用?Java Hyperlink使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


Hyperlink類屬於org.apache.poi.common.usermodel包,在下文中一共展示了Hyperlink類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: setHyperlink

import org.apache.poi.common.usermodel.Hyperlink; //導入依賴的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);
}
 
開發者ID:long47964,項目名稱:excel-utils,代碼行數:39,代碼來源:ExcelExportUtil.java

示例2: setLinkField

import org.apache.poi.common.usermodel.Hyperlink; //導入依賴的package包/類
public ExcelWriteFieldMappingAttribute setLinkField(String linkField) {
    this.linkField = linkField;
    this.linkType = Hyperlink.LINK_URL;
    return this;
}
 
開發者ID:hellojavaer,項目名稱:poi-excel-utils,代碼行數:6,代碼來源:ExcelWriteFieldMapping.java

示例3: setLink

import org.apache.poi.common.usermodel.Hyperlink; //導入依賴的package包/類
public ExcelWriteFieldMappingAttribute setLink(String linkFieldName, int linkType) {
    this.linkField = linkFieldName;
    this.linkType = Hyperlink.LINK_URL;
    return this;
}
 
開發者ID:hellojavaer,項目名稱:poi-excel-utils,代碼行數:6,代碼來源:ExcelWriteFieldMapping.java

示例4: extractCell

import org.apache.poi.common.usermodel.Hyperlink; //導入依賴的package包/類
static protected Cell extractCell(org.apache.poi.ss.usermodel.Cell cell, Map<String, Recon> reconMap) {
    Serializable value = extractCell(cell);
    
    if (value != null) {
        Recon recon = null;
        
        Hyperlink hyperlink = cell.getHyperlink();
        if (hyperlink != null) {
            String url = hyperlink.getAddress();
            
            if (url != null && (url.startsWith("http://") ||
                url.startsWith("https://"))) {
                
                final String sig = "freebase.com/view";
                
                int i = url.indexOf(sig);
                if (i > 0) {
                    String id = url.substring(i + sig.length());
                    
                    int q = id.indexOf('?');
                    if (q > 0) {
                        id = id.substring(0, q);
                    }
                    int h = id.indexOf('#');
                    if (h > 0) {
                        id = id.substring(0, h);
                    }
                    
                    if (reconMap.containsKey(id)) {
                        recon = reconMap.get(id);
                        recon.judgmentBatchSize++;
                    } else {
                        recon = new Recon(0, null, null);
                        recon.service = "import";
                        recon.match = new ReconCandidate(id, value.toString(), new String[0], 100);
                        recon.matchRank = 0;
                        recon.judgment = Judgment.Matched;
                        recon.judgmentAction = "auto";
                        recon.judgmentBatchSize = 1;
                        recon.addCandidate(recon.match);
                        
                        reconMap.put(id, recon);
                    }
                    
                }
            }
        }
        
        return new Cell(value, recon);
    } else {
        return null;
    }
}
 
開發者ID:dfci-cccb,項目名稱:mev,代碼行數:54,代碼來源:ExcelImporter.java


注:本文中的org.apache.poi.common.usermodel.Hyperlink類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。