Java Code Examples for org.apache.poi.ss.usermodel.CreationHelper#createHyperlink()
The following examples show how to use
org.apache.poi.ss.usermodel.CreationHelper#createHyperlink() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: URICellConverterFactory.java From xlsmapper with Apache License 2.0 | 6 votes |
@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); } }
Example 2
Source File: CellLinkCellConverterFactory.java From xlsmapper with Apache License 2.0 | 6 votes |
@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); } }
Example 3
Source File: LinkCellConverterTest.java From xlsmapper with Apache License 2.0 | 6 votes |
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); }
Example 4
Source File: CustomCellWriteHandler.java From easyexcel with Apache License 2.0 | 5 votes |
@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); } }
Example 5
Source File: ExcelCell.java From objectlabkit with Apache License 2.0 | 5 votes |
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; }