本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
}