org.apache.poi.ss.usermodel.Hyperlink#setAddress ( )源码实例Demo

下面列出了org.apache.poi.ss.usermodel.Hyperlink#setAddress ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: xlsmapper   文件: URICellConverterFactory.java
@Override
protected void setupCell(final Cell cell, final Optional<URI> cellValue) throws TypeBindException {
    
    // 既存のハイパーリンクを削除
    // 削除しないと、Excelの見た目上はリンクは変わっているが、データ上は2重にリンクが設定されている。
    cell.removeHyperlink();
    
    if(cellValue.isPresent()) {
        final CreationHelper helper = cell.getSheet().getWorkbook().getCreationHelper();
        final Hyperlink link = helper.createHyperlink(HyperlinkType.URL);
        link.setAddress(cellValue.get().toString());
        cell.setHyperlink(link);
        
        cell.setCellValue(cellValue.get().toString());
        
    } else {
        cell.setCellType(CellType.BLANK);
    }
    
}
 
源代码2 项目: xlsmapper   文件: CellLinkCellConverterFactory.java
@Override
protected void setupCell(final Cell cell, final Optional<CellLink> cellValue) throws TypeBindException {
    
    // 既存のハイパーリンクを削除
    // 削除しないと、Excelの見た目上はリンクは変わっているが、データ上は2重にリンクが設定されている。
    cell.removeHyperlink();
    
    if(cellValue.isPresent()) {
        final CreationHelper helper = cell.getSheet().getWorkbook().getCreationHelper();
        final HyperlinkType type = POIUtils.judgeLinkType(cellValue.get().getLink());
        final Hyperlink link = helper.createHyperlink(type);
        link.setAddress(cellValue.get().getLink());
        cell.setHyperlink(link);
        
        cell.setCellValue(cellValue.get().getLabel());
        
    } else {
        cell.setCellType(CellType.BLANK);
    }
    
}
 
源代码3 项目: xlsmapper   文件: LinkCellConverterTest.java
public String getFormula2(Point point, Cell cell) {

            if(Utils.equals(comment, "空文字")) {
                return null;

            }

            // ダミーでリンクも設定する
            final CreationHelper helper = cell.getSheet().getWorkbook().getCreationHelper();
            final Hyperlink link = helper.createHyperlink(HyperlinkType.URL);
            link.setAddress(comment);
            cell.setHyperlink(link);

            final int rowNumber = point.y + 1;
            return String.format("HYPERLINK(D%s,\"リンク\"&A%s)", rowNumber, rowNumber);
        }
 
源代码4 项目: easyexcel   文件: CustomCellWriteHandler.java
@Override
public void afterCellDispose(WriteSheetHolder writeSheetHolder, WriteTableHolder writeTableHolder,
    List<CellData> cellDataList, Cell cell, Head head, Integer relativeRowIndex, Boolean isHead) {
    // 这里可以对cell进行任何操作
    LOGGER.info("第{}行,第{}列写入完成。", cell.getRowIndex(), cell.getColumnIndex());
    if (isHead && cell.getColumnIndex() == 0) {
        CreationHelper createHelper = writeSheetHolder.getSheet().getWorkbook().getCreationHelper();
        Hyperlink hyperlink = createHelper.createHyperlink(HyperlinkType.URL);
        hyperlink.setAddress("https://github.com/alibaba/easyexcel");
        cell.setHyperlink(hyperlink);
    }
}
 
源代码5 项目: myexcel   文件: AbstractExcelFactory.java
private Cell setLink(Td td, Row currentRow, HyperlinkType hyperlinkType) {
    if (StringUtil.isBlank(td.getContent())) {
        return currentRow.createCell(td.getCol());
    }
    if (createHelper == null) {
        createHelper = workbook.getCreationHelper();
    }
    Cell cell = currentRow.createCell(td.getCol(), CellType.STRING);
    cell.setCellValue(td.getContent());
    Hyperlink link = createHelper.createHyperlink(hyperlinkType);
    link.setAddress(td.getLink());
    cell.setHyperlink(link);
    return cell;
}
 
源代码6 项目: sakai   文件: EventWorksheet.java
private Hyperlink setAttachmentURLLinks(SignupAttachment attach) {
	Hyperlink hsHyperlink = wb.getCreationHelper().createHyperlink(HyperlinkType.URL);
	String link = this.sakaiFacade.getServerConfigurationService().getServerUrl()
			+ attach.getLocation();
	hsHyperlink.setAddress(link);
	hsHyperlink.setLabel(attach.getFilename());
	return hsHyperlink;
}
 
源代码7 项目: objectlabkit   文件: ExcelCell.java
public ExcelCell link(String url, String label) {
    final CreationHelper creationHelper = row().sheet().workbook().poiWorkbook().getCreationHelper();
    final Hyperlink hl = creationHelper.createHyperlink(HyperlinkType.URL);
    hl.setAddress(url);
    hl.setLabel(label);
    currentCell.setCellValue(label);
    currentCell.setHyperlink(hl);
    style(LINK);
    return this;
}
 
源代码8 项目: sakai   文件: EventWorksheet.java
private Hyperlink setAttachmentURLLinks(SignupAttachment attach) {
	Hyperlink hsHyperlink = wb.getCreationHelper().createHyperlink(HyperlinkType.URL);
	String link = this.sakaiFacade.getServerConfigurationService().getServerUrl()
			+ attach.getLocation();
	hsHyperlink.setAddress(link);
	hsHyperlink.setLabel(attach.getFilename());
	return hsHyperlink;
}
 
 同类方法