Java 类org.apache.poi.xssf.usermodel.XSSFHyperlink 实例源码

项目:excella-core    文件:PoiUtil.java   
/**
 * セルにハイパーリンクを設定する。
 * 
 * @param cell セル
 * @param type リンクタイプ
 * @param address ハイパーリンクアドレス
 * @see org.apache.poi.common.usermodel.Hyperlink
 */
public static void setHyperlink( Cell cell, HyperlinkType hyperlinkType, String address) {

    Workbook wb = cell.getRow().getSheet().getWorkbook();

    CreationHelper createHelper = wb.getCreationHelper();

    Hyperlink link = createHelper.createHyperlink( hyperlinkType);
    if ( link instanceof HSSFHyperlink) {
        (( HSSFHyperlink) link).setTextMark( address);
    } else if ( link instanceof XSSFHyperlink) {
        (( XSSFHyperlink) link).setAddress( address);
    }

    cell.setHyperlink( link);
}
项目:owsi-core-parent    文件:UserExcelTableExport.java   
private void populateRow(Row row, User user) {
    UserBinding binding = new UserBinding(user);

    int columnIndex = 0;

    addTextCell(row, columnIndex++, binding.userName().getSafely());
    addTextCell(row, columnIndex++, binding.lastName().getSafely());
    addTextCell(row, columnIndex++, binding.firstName().getSafely());

    XSSFCreationHelper helper= (XSSFCreationHelper) workbook.getCreationHelper();
    XSSFHyperlink emailLink = helper.createHyperlink(Hyperlink.LINK_EMAIL);
    String emailAddress = binding.email().getSafely();
    emailLink.setAddress("mailto:" + emailAddress);
    addLinkToCell(addTextCell(row, columnIndex++, emailAddress), emailLink);

    if (binding.active().getSafely()) {
        addTextCell(row, columnIndex++, "Oui");
    }
    else {
        addTextCell(row, columnIndex++, "Non");
    }

    if (binding.creationDate().getSafely() != null) {
        addDateCell(row, columnIndex++, binding.creationDate().getSafely());
    } else {
        addTextCell(row, columnIndex++, "");
    }

    if (binding.lastUpdateDate().getSafely() != null) {
        addDateCell(row, columnIndex++, binding.lastUpdateDate().getSafely());
    } else {
        addTextCell(row, columnIndex++, "");
    }

    if (binding.lastLoginDate().getSafely() != null) {
        addDateCell(row, columnIndex++, binding.lastLoginDate().getSafely());
    } else {
        addTextCell(row, columnIndex++, "");
    }
}