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


Java CreationHelper.createRichTextString方法代码示例

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


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

示例1: setComment

import org.apache.poi.ss.usermodel.CreationHelper; //导入方法依赖的package包/类
/**
 * See the comment for the given cell
 * 
 * @param cell
 *            the cell
 * @param message
 *            the comment message
 */
public static void setComment(HSSFCell cell, String message) {
	Drawing drawing = cell.getSheet().createDrawingPatriarch();
	CreationHelper factory = cell.getSheet().getWorkbook().getCreationHelper();

	// When the comment box is visible, have it show in a 1x3 space
	ClientAnchor anchor = factory.createClientAnchor();
	anchor.setCol1(cell.getColumnIndex());
	anchor.setCol2(cell.getColumnIndex() + 1);
	anchor.setRow1(cell.getRowIndex());
	anchor.setRow2(cell.getRowIndex() + 1);
	anchor.setDx1(100);
	anchor.setDx2(1000);
	anchor.setDy1(100);
	anchor.setDy2(1000);

	// Create the comment and set the text+author
	Comment comment = drawing.createCellComment(anchor);
	RichTextString str = factory.createRichTextString(message);
	comment.setString(str);
	comment.setAuthor("TURNUS");
	// Assign the comment to the cell
	cell.setCellComment(comment);
}
 
开发者ID:turnus,项目名称:turnus,代码行数:32,代码来源:PoiUtils.java

示例2: createCellComment

import org.apache.poi.ss.usermodel.CreationHelper; //导入方法依赖的package包/类
private Comment createCellComment(String author, String comment) {

		// comments only supported for XLSX
		if (data.sheet instanceof XSSFSheet) {
			CreationHelper factory = data.wb.getCreationHelper();
			Drawing drawing = data.sheet.createDrawingPatriarch();

			ClientAnchor anchor = factory.createClientAnchor();
			Comment cmt = drawing.createCellComment(anchor);
			RichTextString str = factory.createRichTextString(comment);
			cmt.setString(str);
			cmt.setAuthor(author);
			return cmt;

		}
		return null;

	}
 
开发者ID:yintaoxue,项目名称:read-open-source-code,代码行数:19,代码来源:ExcelWriterStep.java

示例3: createCellComment

import org.apache.poi.ss.usermodel.CreationHelper; //导入方法依赖的package包/类
private Comment createCellComment( String author, String comment ) {

    // comments only supported for XLSX
    if ( data.sheet instanceof XSSFSheet ) {
      CreationHelper factory = data.wb.getCreationHelper();
      Drawing drawing = data.sheet.createDrawingPatriarch();

      ClientAnchor anchor = factory.createClientAnchor();
      Comment cmt = drawing.createCellComment( anchor );
      RichTextString str = factory.createRichTextString( comment );
      cmt.setString( str );
      cmt.setAuthor( author );
      return cmt;

    }
    return null;

  }
 
开发者ID:pentaho,项目名称:pentaho-kettle,代码行数:19,代码来源:ExcelWriterStep.java

示例4: set

import org.apache.poi.ss.usermodel.CreationHelper; //导入方法依赖的package包/类
/**
 * 保持している情報を元に、シートのセルにコメントを設定する。
 * @param sheet
 * @return POIの設定したコメントオブジェクト。
 * @throws IllegalArgumentException sheet is null.
 */
public Comment set(final Sheet sheet) {
    ArgUtils.notNull(sheet, "sheet");
    
    final CreationHelper helper = sheet.getWorkbook().getCreationHelper();
    final Drawing drawing = sheet.createDrawingPatriarch();
    
    // コメントの位置、サイズの指定
    int col1 = column + 1;
    int row1 = row;
    
    if(sheet instanceof HSSFSheet) {
        // 2003形式の場合は、行の位置をずらす。
        row1--;
    }
    
    int col2 = col1 + anchor.columnSize;
    int row2 = row1 + anchor.rowSize;
    final ClientAnchor clientAnchor = drawing.createAnchor(
            anchor.dx1, anchor.dy1, anchor.dx2, anchor.dy2,
            col1, row1, col2, row2
            );
    POIUtils.setClientAnchorType(clientAnchor, anchor.type);
    
    final Comment comment = drawing.createCellComment(clientAnchor);
    comment.setColumn(column);
    comment.setRow(row);
    comment.setAuthor(author);
    comment.setVisible(visible);
    
    // 装飾を適用する。
    final RichTextString richText = helper.createRichTextString(text.text);
    if(text.fonts != null) {
        for(TextFontStore fontStore : text.fonts) {
            if(fontStore.font != null) {
                richText.applyFont(fontStore.startIndex, fontStore.endIndex, fontStore.font);
            } else {
                richText.applyFont(fontStore.startIndex, fontStore.endIndex, fontStore.fontIndex);
            }
        }
    }
    
    comment.setString(richText);
    
    return comment;
    
}
 
开发者ID:mygreen,项目名称:xlsmapper,代码行数:53,代码来源:CellCommentStore.java

示例5: createFormattedString

import org.apache.poi.ss.usermodel.CreationHelper; //导入方法依赖的package包/类
/**
 * Construct a <code>RichTextString</code> of the same type as
 * <code>richTextString</code>, format it, and return it.
 * @param numFormattingRuns The number of formatting runs.
 * @param value The new string value of the new <code>RichTextString</code>
 *    to construct.
 * @param helper A <code>CreationHelper</code> that can create the proper
 *    <code>RichTextString</code>.
 * @param formattingRuns A <code>List</code> of <code>FormattingRuns</code>.
 * @return A new <code>RichTextString</code>, the same type as
 *    <code>richTextString</code>, with <code>value</code> as it contents,
 *    formatted as specified.
 */
public static RichTextString createFormattedString(int numFormattingRuns,
   CreationHelper helper, String value, List<FormattingRun> formattingRuns)
{
   // Construct the proper RichTextString.
   RichTextString newString = helper.createRichTextString(value);

   formatString(newString, numFormattingRuns, formattingRuns);
   return newString;
}
 
开发者ID:rmage,项目名称:gnvc-ims,代码行数:23,代码来源:RichTextStringUtil.java


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