本文整理匯總了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;
}