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


Java Hyperlink类代码示例

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


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

示例1: CellSettings

import org.apache.poi.ss.usermodel.Hyperlink; //导入依赖的package包/类
public CellSettings(
	CellType cellType,
	HSSFCellStyle cellStyle,
	Object cellValue,
	String formula,
	Hyperlink link
	) 
{
	this.cellType = cellType;
	this.cellStyle = cellStyle;
	this.cellValue = cellValue;
	this.formula = formula;
	this.link = link;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:15,代码来源:JRXlsMetadataExporter.java

示例2: importValues

import org.apache.poi.ss.usermodel.Hyperlink; //导入依赖的package包/类
public void importValues(				
	CellType cellType,
	HSSFCellStyle cellStyle,
	Object cellValue,
	String formula,
	Hyperlink link
	) 
{
	this.cellType = cellType;
	this.cellStyle = cellStyle;
	this.cellValue = cellValue;
	this.formula = formula;
	this.link = link;
}
 
开发者ID:TIBCOSoftware,项目名称:jasperreports,代码行数:15,代码来源:JRXlsMetadataExporter.java

示例3: 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

示例4: 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

示例5: setHyperlink

import org.apache.poi.ss.usermodel.Hyperlink; //导入依赖的package包/类
/**
 * セルにハイパーリンクを設定する。
 * 
 * @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);
}
 
开发者ID:excella-core,项目名称:excella-core,代码行数:24,代码来源:PoiUtil.java

示例6: 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

示例7: 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

示例8: validateAttributes

import org.apache.poi.ss.usermodel.Hyperlink; //导入依赖的package包/类
/**
 * Validates the attributes for this <code>Tag</code>.  This tag must be
 * bodiless.  The type must be valid.
 */
@SuppressWarnings("unchecked")
public void validateAttributes() throws TagParseException
{
   super.validateAttributes();
   if (!isBodiless())
      throw new TagParseException("Hyperlink tags must not have a body.");

   TagContext context = getContext();
   Map<String, Object> beans = context.getBeans();
   Map<String, RichTextString> attributes = getAttributes();

   String type = AttributeUtil.evaluateStringSpecificValues(attributes.get(ATTR_TYPE), beans, ATTR_TYPE,
      Arrays.asList(TYPE_URL, TYPE_EMAIL, TYPE_FILE, TYPE_DOC), TYPE_URL);
   if (TYPE_URL.equals(type))
         myLinkType = Hyperlink.LINK_URL;
      else if (TYPE_EMAIL.equals(type))
         myLinkType = Hyperlink.LINK_EMAIL;
      else if (TYPE_FILE.equals(type))
         myLinkType = Hyperlink.LINK_FILE;
      else if (TYPE_DOC.equals(type))
         myLinkType = Hyperlink.LINK_DOCUMENT;

   myAddress = AttributeUtil.evaluateStringNotNull(attributes.get(ATTR_ADDRESS), beans, ATTR_ADDRESS, null);

   myValue = attributes.get(ATTR_VALUE);
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:31,代码来源:HyperlinkTag.java

示例9: 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

示例10: 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

示例11: 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

示例12: populateRow

import org.apache.poi.ss.usermodel.Hyperlink; //导入依赖的package包/类
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++, "");
	}
}
 
开发者ID:openwide-java,项目名称:owsi-core-parent,代码行数:41,代码来源:UserExcelTableExport.java

示例13: 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

示例14: addBooleanCell

import org.apache.poi.ss.usermodel.Hyperlink; //导入依赖的package包/类
public static int addBooleanCell(Sheet sheet, int col, int row, int width, int height,
        CellStyle cellStyle, Boolean value, Hyperlink link) {
    if (value == null) {
        return addBlankCell(sheet, col, row, width, height, cellStyle, link);
    }
    Cell cell = createCell(sheet, col, row, width, height, cellStyle, CELL_TYPE_BOOLEAN, link);
    cell.setCellValue(value.booleanValue());
    return width;
}
 
开发者ID:brightgenerous,项目名称:brigen-base,代码行数:10,代码来源:PoiMethods.java

示例15: addLabelCell

import org.apache.poi.ss.usermodel.Hyperlink; //导入依赖的package包/类
public static int addLabelCell(Sheet sheet, int col, int row, int width, int height,
        CellStyle cellStyle, String value, Hyperlink link) {
    if (value == null) {
        return addBlankCell(sheet, col, row, width, height, cellStyle, link);
    }
    Cell cell = createCell(sheet, col, row, width, height, cellStyle, CELL_TYPE_STRING, link);
    cell.setCellValue(value);
    return width;
}
 
开发者ID:brightgenerous,项目名称:brigen-base,代码行数:10,代码来源:PoiMethods.java


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