本文整理汇总了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);
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}