当前位置: 首页>>代码示例>>Java>>正文


Java Hyperlink.setAddress方法代码示例

本文整理汇总了Java中org.apache.poi.ss.usermodel.Hyperlink.setAddress方法的典型用法代码示例。如果您正苦于以下问题:Java Hyperlink.setAddress方法的具体用法?Java Hyperlink.setAddress怎么用?Java Hyperlink.setAddress使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.poi.ss.usermodel.Hyperlink的用法示例。


在下文中一共展示了Hyperlink.setAddress方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setLink

import org.apache.poi.ss.usermodel.Hyperlink; //导入方法依赖的package包/类
/**
 * Set a link to a cell. The link type should one of {@link Hyperlink}
 * 
 * @param wb
 *            the workbook which contains the cell
 * @param cell
 *            the cell where the link is stored
 * @param address
 *            the cell destination address
 * @param linkType
 *            the type selected among {@link Hyperlink}
 */
public static void setLink(Workbook wb, HSSFCell cell, String address, int linkType) {
	CreationHelper helper = wb.getCreationHelper();
	CellStyle style = wb.createCellStyle();
	Font font = wb.createFont();
	font.setUnderline(Font.U_SINGLE);
	font.setColor(IndexedColors.BLUE.getIndex());
	style.setFont(font);

	Hyperlink link = helper.createHyperlink(linkType);
	link.setAddress(address);
	cell.setHyperlink(link);
	cell.setCellStyle(style);
}
 
开发者ID:turnus,项目名称:turnus,代码行数:26,代码来源:PoiUtils.java

示例2: main

import org.apache.poi.ss.usermodel.Hyperlink; //导入方法依赖的package包/类
public static void main(String[] args)throws Exception
{
	String dataPath = "src/featurescomparison/workingwithdata/hyperlink/data/";
	
	Workbook wb = new XSSFWorkbook(); //or new HSSFWorkbook();
    CreationHelper createHelper = wb.getCreationHelper();

    //cell style for hyperlinks
    //by default hyperlinks are blue and underlined
    CellStyle hlink_style = wb.createCellStyle();
    Font hlink_font = wb.createFont();
    hlink_font.setUnderline(Font.U_SINGLE);
    hlink_font.setColor(IndexedColors.BLUE.getIndex());
    hlink_style.setFont(hlink_font);

    Cell cell;
    Sheet sheet = wb.createSheet("Hyperlinks");
    //URL
    cell = sheet.createRow(0).createCell((short)0);
    cell.setCellValue("URL Link");

    Hyperlink link = createHelper.createHyperlink(Hyperlink.LINK_URL);
    link.setAddress("http://poi.apache.org/");
    cell.setHyperlink(link);
    cell.setCellStyle(hlink_style);

    //link to a file in the current directory
    cell = sheet.createRow(1).createCell((short)0);
    cell.setCellValue("File Link");
    link = createHelper.createHyperlink(Hyperlink.LINK_FILE);
    link.setAddress("link1.xls");
    cell.setHyperlink(link);
    cell.setCellStyle(hlink_style);

    //e-mail link
    cell = sheet.createRow(2).createCell((short)0);
    cell.setCellValue("Email Link");
    link = createHelper.createHyperlink(Hyperlink.LINK_EMAIL);
    //note, if subject contains white spaces, make sure they are url-encoded
    link.setAddress("mailto:[email protected]?subject=Hyperlinks");
    cell.setHyperlink(link);
    cell.setCellStyle(hlink_style);

    //link to a place in this workbook

    //create a target sheet and cell
    Sheet sheet2 = wb.createSheet("Target Sheet");
    sheet2.createRow(0).createCell((short)0).setCellValue("Target Cell");

    cell = sheet.createRow(3).createCell((short)0);
    cell.setCellValue("Worksheet Link");
    Hyperlink link2 = createHelper.createHyperlink(Hyperlink.LINK_DOCUMENT);
    link2.setAddress("'Target Sheet'!A1");
    cell.setHyperlink(link2);
    cell.setCellStyle(hlink_style);

    FileOutputStream out = new FileOutputStream(dataPath + "ApacheHyperlinks.xlsx");
    wb.write(out);
    out.close();
    
    System.out.println("Done..");
}
 
开发者ID:asposemarketplace,项目名称:Aspose_for_Apache_POI,代码行数:63,代码来源:ApacheHyperlinks.java

示例3: removeHyperlink

import org.apache.poi.ss.usermodel.Hyperlink; //导入方法依赖的package包/类
/**
 * セルに設定されているハイパーリンクを削除する。
 * <p>POIのバージョンによって、{@link Cell#removeHyperlink()}のネイティブのメソッドを呼び出す。
 * @since 0.4
 * @param cell
 * @return true: ハイパーリンクが設定されており削除できた場合。false:ハイパーリンクが設定されていない場合。
 * @throws IllegalArgumentException cell == null.
 */
public static boolean removeHyperlink(final Cell cell) {
    
    ArgUtils.notNull(cell, "cell");
    
    final Hyperlink link = cell.getHyperlink();
    if(link == null) {
        return false;
    }
    
    if(AVAILABLE_METHOD_CELL_REMOVE_HYPERLINK) {
        cell.removeHyperlink();
        return true;
    } else {
        // 既存のハイパーリンクのURLをクリアし、再設定する。
        link.setAddress("");
        cell.setHyperlink(link);
        return true;
    }
    
}
 
开发者ID:mygreen,项目名称:xlsmapper,代码行数:29,代码来源:POIUtils.java

示例4: getFormula2

import org.apache.poi.ss.usermodel.Hyperlink; //导入方法依赖的package包/类
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(Hyperlink.LINK_URL);
    link.setAddress(comment);
    cell.setHyperlink(link);
    
    final int rowNumber = point.y + 1;
    return String.format("HYPERLINK(D%s,\"リンク\"&A%s)", rowNumber, rowNumber);
}
 
开发者ID:mygreen,项目名称:xlsmapper,代码行数:17,代码来源:LinkCellConverterTest.java

示例5: process

import org.apache.poi.ss.usermodel.Hyperlink; //导入方法依赖的package包/类
/**
 * <p>Place the Hyperlink in the Cell, which replaces any other value left
 * behind in the Cell.</p>
 * @return Whether the first <code>Cell</code> in the <code>Block</code>
 *    associated with this <code>Tag</code> was processed.
 */
public boolean process()
{
   TagContext context = getContext();
   Sheet sheet = context.getSheet();
   Block block = context.getBlock();
   int left = block.getLeftColNum();
   int top = block.getTopRowNum();
   // It should exist in this Cell; this Tag was found in it.
   Row row = sheet.getRow(top);
   Cell cell = row.getCell(left);
   SheetUtil.setCellValue(cell, myValue);

   CreationHelper helper = sheet.getWorkbook().getCreationHelper();
   Hyperlink hyperlink = helper.createHyperlink(myLinkType);
   hyperlink.setAddress(myAddress);
   cell.setHyperlink(hyperlink);

   BlockTransformer transformer = new BlockTransformer();
   transformer.transform(context, getWorkbookContext());

   return true;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:29,代码来源:HyperlinkTag.java

示例6: addFooter

import org.apache.poi.ss.usermodel.Hyperlink; //导入方法依赖的package包/类
/**
 * Adds the footer.
 */
private void addFooter() {
    nextRow();
    nextRow();
    cell.setCellValue("Produced by gedantic");

    Hyperlink link = wb.getCreationHelper().createHyperlink(org.apache.poi.common.usermodel.Hyperlink.LINK_URL);
    link.setAddress("http://gedantic.org");
    cell.setHyperlink(link);

    cell.setCellStyle(styleHyperlink);

}
 
开发者ID:frizbog,项目名称:gedantic,代码行数:16,代码来源:WorkbookCreator.java

示例7: writeWorkbook

import org.apache.poi.ss.usermodel.Hyperlink; //导入方法依赖的package包/类
private void writeWorkbook() throws java.io.IOException {
    Workbook wb = new XSSFWorkbook();
    try {
        Sheet sheet = wb.createSheet("Sheet1");
        Row row = sheet.createRow(0);
        Cell cell = row.createCell(0);
        cell.setCellValue("cell-1");
        cell = row.createCell(1);
        cell.setCellValue("cell-2");
        cell = row.createCell(2);
        cell.setCellValue("cell-3");

        XSSFCellStyle style = (XSSFCellStyle) wb.createCellStyle();
        style.setFillBackgroundColor(new XSSFColor(new org.apache.poi.java.awt.Color(1, 2, 3)));

        Hyperlink link = wb.getCreationHelper().createHyperlink(HyperlinkType.URL);
        link.setAddress("http://www.google.at");
        link.setLabel("Google");
        cell.setHyperlink(link);

        cell.setCellStyle(style);

        sheet.setPrintGridlines(true);

        OutputStream stream = openFileOutput("test.xlsx", Context.MODE_PRIVATE);
        try {
            wb.write(stream);
        } finally {
            stream.close();
        }
    } finally {
        wb.close();
    }
}
 
开发者ID:centic9,项目名称:poi-on-android,代码行数:35,代码来源:DocumentListActivity.java

示例8: setAttachmentURLLinks

import org.apache.poi.ss.usermodel.Hyperlink; //导入方法依赖的package包/类
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;
}
 
开发者ID:sakaiproject,项目名称:sakai,代码行数:9,代码来源:EventWorksheet.java

示例9: writeRow

import org.apache.poi.ss.usermodel.Hyperlink; //导入方法依赖的package包/类
public void writeRow(
		ArrayList<IdentifiedFilesRow> identifiedFilesRowList) {

	for(IdentifiedFilesRow identifiedFilesRow:identifiedFilesRowList) {
		Row row = sheet.createRow(curRow++);

		Cell cell = row.createCell(ISheetTemplate.COL_A);
		cell.setCellValue(identifiedFilesRow.getProjectName());
		cell.setCellStyle(normalStyle);

		cell = row.createCell(ISheetTemplate.COL_B);
		cell.setCellValue(identifiedFilesRow.getFullPath());
		cell.setCellStyle(leftStyle);

		cell = row.createCell(ISheetTemplate.COL_C);
		cell.setCellValue(identifiedFilesRow.getComponent());
		cell.setCellStyle(normalStyle);

		cell = row.createCell(ISheetTemplate.COL_D);
		cell.setCellValue(identifiedFilesRow.getLicense());
		cell.setCellStyle(normalStyle);

		cell = row.createCell(ISheetTemplate.COL_E);
		cell.setCellValue(identifiedFilesRow.getDiscoveryType());
		cell.setCellStyle(normalStyle);

		cell = row.createCell(ISheetTemplate.COL_F);
		cell.setCellStyle(normalStyle);
		String value = "";
		String url = identifiedFilesRow.getUrl();
		if(url != null && (url.length() != 0) && !"null".equals(url)) {
			Hyperlink link = wb.getCreationHelper().createHyperlink(Hyperlink.LINK_URL);
		    link.setAddress(url);
			link.setLabel(url);
			
			cell.setHyperlink(link);
			cell.setCellStyle(getCellStyle(WHITE, getFont(BLUE,(short)10,false)));
			value = "Show Matched Code ("+(identifiedFilesRow.getCodeMatchCnt())+")";
		}
		cell.setCellValue(value);

		cell = row.createCell(ISheetTemplate.COL_G);
		cell.setCellValue(identifiedFilesRow.getComment());
		cell.setCellStyle(leftStyle);

	}
}
 
开发者ID:spdx,项目名称:ATTIC-osit,代码行数:48,代码来源:IdentifiedFilesSheetTemplate.java

示例10: toCell

import org.apache.poi.ss.usermodel.Hyperlink; //导入方法依赖的package包/类
@Override
public Cell toCell(final FieldAdaptor adaptor, final URI targetValue, final Object targetBean,
        final Sheet sheet, final int column, final int row,
        final XlsMapperConfig config) throws XlsMapperException {
    
    final XlsConverter converterAnno = adaptor.getSavingAnnotation(XlsConverter.class);
    final XlsFormula formulaAnno = adaptor.getSavingAnnotation(XlsFormula.class);
    final boolean primaryFormula = formulaAnno == null ? false : formulaAnno.primary();
    
    final Cell cell = POIUtils.getCell(sheet, column, row);
    
    // セルの書式設定
    if(converterAnno != null) {
        POIUtils.wrapCellText(cell, converterAnno.wrapText());
        POIUtils.shrinkToFit(cell, converterAnno.shrinkToFit());
    }
    
    URI value = targetValue;
    
    // 既存のハイパーリンクを削除
    // 削除しないと、Excelの見た目上はリンクは変わっているが、データ上は2重にリンクが設定されている。
    POIUtils.removeHyperlink(cell);
    
    if(value != null && !primaryFormula) {
        
        final CreationHelper helper = sheet.getWorkbook().getCreationHelper();
        final Hyperlink link = helper.createHyperlink(Hyperlink.LINK_URL);
        link.setAddress(value.toString());
        cell.setHyperlink(link);
        
        cell.setCellValue(value.toString());
        
    } else if(formulaAnno != null) {
        Utils.setupCellFormula(adaptor, formulaAnno, config, cell, targetBean);
        
    } else {
        cell.setCellType(Cell.CELL_TYPE_BLANK);
    }
    
    return cell;
}
 
开发者ID:mygreen,项目名称:xlsmapper,代码行数:42,代码来源:URICellConverter.java

示例11: toCell

import org.apache.poi.ss.usermodel.Hyperlink; //导入方法依赖的package包/类
@Override
public Cell toCell(final FieldAdaptor adaptor, final CellLink targetValue, final Object targetBean,
        final Sheet sheet, final int column, final int row, final XlsMapperConfig config) throws XlsMapperException {
    
    final XlsConverter converterAnno = adaptor.getSavingAnnotation(XlsConverter.class);
    final XlsFormula formulaAnno = adaptor.getSavingAnnotation(XlsFormula.class);
    final boolean primaryFormula = formulaAnno == null ? false : formulaAnno.primary();
    
    final Cell cell = POIUtils.getCell(sheet, column, row);
    
    // セルの書式設定
    if(converterAnno != null) {
        POIUtils.wrapCellText(cell, converterAnno.wrapText());
        POIUtils.shrinkToFit(cell, converterAnno.shrinkToFit());
    }
    
    final CellLink value = targetValue;
    
    // 既存のハイパーリンクを削除
    // 削除しないと、Excelの見た目上はリンクは変わっているが、データ上は2重にリンクが設定されている。
    POIUtils.removeHyperlink(cell);
    
    if(value != null && Utils.isNotEmpty(value.getLink()) && !primaryFormula) {
        final CreationHelper helper = sheet.getWorkbook().getCreationHelper();
        final LinkType type = POIUtils.judgeLinkType(value.getLink());
        final Hyperlink link = helper.createHyperlink(type.poiType());
        
        link.setAddress(value.getLink());
        cell.setHyperlink(link);
        cell.setCellValue(value.getLabel());
        
    } else if(value != null && Utils.isNotEmpty(value.getLabel()) && !primaryFormula) {
        // 見出しのみ設定されている場合
        cell.setCellValue(value.getLabel());
        
    } else if(formulaAnno != null) {
        Utils.setupCellFormula(adaptor, formulaAnno, config, cell, targetBean);
        
    } else {
        cell.setCellType(Cell.CELL_TYPE_BLANK);
    }
    
    return cell;
}
 
开发者ID:mygreen,项目名称:xlsmapper,代码行数:45,代码来源:CellLinkCellConverter.java


注:本文中的org.apache.poi.ss.usermodel.Hyperlink.setAddress方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。