本文整理汇总了Java中org.apache.poi.ss.usermodel.Drawing.createCellComment方法的典型用法代码示例。如果您正苦于以下问题:Java Drawing.createCellComment方法的具体用法?Java Drawing.createCellComment怎么用?Java Drawing.createCellComment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.poi.ss.usermodel.Drawing
的用法示例。
在下文中一共展示了Drawing.createCellComment方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setComment
import org.apache.poi.ss.usermodel.Drawing; //导入方法依赖的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.Drawing; //导入方法依赖的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.Drawing; //导入方法依赖的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: writeHeader
import org.apache.poi.ss.usermodel.Drawing; //导入方法依赖的package包/类
protected void writeHeader(Sheet sheet, Drawing drawing, Row nameRow, Row labelRow, int i, ExcelColumn column, CellStyle boldStyle)
{
CreationHelper helper = sheet.getWorkbook().getCreationHelper();
// Notify the listeners
for (ExcelExportListener listener : listeners)
{
listener.preHeader(column);
}
nameRow.createCell(i).setCellValue(helper.createRichTextString(column.getAttributeName()));
Cell cell = labelRow.createCell(i);
cell.setCellValue(helper.createRichTextString(column.getDisplayLabel()));
if (column.isRequired() && boldStyle != null)
{
cell.setCellStyle(boldStyle);
}
if (column.getDescription() != null && column.getDescription().length() > 0)
{
ClientAnchor anchor = helper.createClientAnchor();
anchor.setDx1(0);
anchor.setDy1(0);
anchor.setDx2(0);
anchor.setDy2(0);
anchor.setCol1(0);
anchor.setRow1(0);
anchor.setCol2(0);
anchor.setRow2(4);
Comment comment = drawing.createCellComment(anchor);
comment.setString(helper.createRichTextString(column.getDescription()));
cell.setCellComment(comment);
}
sheet.autoSizeColumn((short) i);
}
示例5: set
import org.apache.poi.ss.usermodel.Drawing; //导入方法依赖的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;
}