Java 类org.apache.poi.ss.usermodel.Comment 实例源码
项目:turnus
文件:PoiUtils.java
/**
* 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);
}
项目:excella-reports
文件:ImageParamParser.java
/**
* シートにコメントが設定されているかを取得する。
*
* @param sheet シート
* @return 有:true/無:false
*/
private boolean hasComments( Sheet sheet) {
if ( sheet instanceof XSSFSheet) {
XSSFSheet xssfSheet = ( XSSFSheet) sheet;
return xssfSheet.hasComments();
} else if ( sheet instanceof HSSFSheet) {
Iterator<Row> rowIterator = sheet.iterator();
while ( rowIterator.hasNext()) {
Row row = rowIterator.next();
Iterator<Cell> cellIterator = row.iterator();
while ( cellIterator.hasNext()) {
Cell cell = cellIterator.next();
Comment comment = cell.getCellComment();
if ( comment != null) {
return true;
}
}
}
}
return false;
}
项目:read-open-source-code
文件:ExcelWriterStep.java
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;
}
项目:kettle-4.4.0-stable
文件:ExcelWriterStep.java
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;
}
项目:kettle-trunk
文件:ExcelWriterStep.java
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;
}
项目:pentaho-kettle
文件:ExcelWriterStep.java
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;
}
项目:wandora
文件:AbstractExcelExtractor.java
public Topic getCommentTopic(Cell cell, TopicMap tm) throws TopicMapException {
Comment comment = cell.getCellComment();
if(comment != null) {
RichTextString rts = comment.getString();
String str = rts.getString();
String basename = str.replace('\n', ' ');
basename = basename.replace('\r', ' ');
basename = basename.replace('\t', ' ');
Topic topic=getOrCreateTopic(tm, EXCEL_COMMENT_SI_PREFIX+"/"+urlEncode(basename), basename);
topic.setData(getCommentTypeTopic(tm), tm.getTopic(XTMPSI.getLang(DEFAULT_LANG)), str);
topic.addType(getCommentTypeTopic(tm));
return topic;
}
return null;
}
项目:xlsmapper
文件:CellCommentStore.java
/**
* セルのコメントを取得する。その際に、コメントを削除する。
* @param cell
* @return コメントが設定されていない場合は、nullを返す。
*/
public static CellCommentStore getAndRemove(final Cell cell) {
ArgUtils.notNull(cell, "cell");
final Comment comment = cell.getCellComment();
if(comment == null) {
return null;
}
final CellCommentStore commentStore = get(comment);
cell.removeCellComment();
return commentStore;
}
项目:xlsmapper
文件:CellCommentStore.java
/**
* セルのコメントを取得する。
* @param comment 元となるPOIのセルノコメント。
* @return
* @throws IllegalArgumentException comment is null.
*/
public static CellCommentStore get(final Comment comment) {
ArgUtils.notNull(comment, "comment");
final CellCommentStore dest = new CellCommentStore();
dest.column = comment.getColumn();
dest.row = comment.getRow();
dest.author = comment.getAuthor();
dest.text = TextStore.get(comment.getString());
dest.visible = comment.isVisible();
dest.anchor = AnchorStore.get(comment.getClientAnchor());
return dest;
}
项目:Runway-SDK
文件:ExcelExportSheet.java
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);
}
项目:excel2canvas
文件:ExcelToCanvasBuilder.java
private String getComment() {
if (this.cell == null || this.cell.getCellComment() == null) {
return null;
}
Comment comment = this.cell.getCellComment();
String value = comment.getString() == null ? null : comment.getString().getString();
if (value != null) {
value = convertHtml(value);
}
return value;
}
项目:ExcelHandle
文件:ExportExcel.java
/**
* 初始化函数
* @param title 表格标题,传“空值”,表示无标题
* @param headerList 表头列表
*/
private void initialize(String title, List<String> headerList) {
this.wb = new SXSSFWorkbook(500);
this.sheet = wb.createSheet("Export");
this.styles = createStyles(wb);
// Create title
if (StringUtils.isNotBlank(title)){
Row titleRow = sheet.createRow(rownum++);
titleRow.setHeightInPoints(30);
Cell titleCell = titleRow.createCell(0);
titleCell.setCellStyle(styles.get("title"));
titleCell.setCellValue(title);
sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),
titleRow.getRowNum(), titleRow.getRowNum(), headerList.size()-1));
}
// Create header
if (headerList == null){
throw new RuntimeException("headerList not null!");
}
Row headerRow = sheet.createRow(rownum++);
headerRow.setHeightInPoints(16);
for (int i = 0; i < headerList.size(); i++) {
Cell cell = headerRow.createCell(i);
cell.setCellStyle(styles.get("header"));
String[] ss = StringUtils.split(headerList.get(i), "**", 2);
if (ss.length==2){
cell.setCellValue(ss[0]);
Comment comment = this.sheet.createDrawingPatriarch().createCellComment(
new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
comment.setString(new XSSFRichTextString(ss[1]));
cell.setCellComment(comment);
}else{
cell.setCellValue(headerList.get(i));
}
sheet.autoSizeColumn(i);
}
for (int i = 0; i < headerList.size(); i++) {
int colWidth = sheet.getColumnWidth(i)*2;
sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);
}
log.debug("Initialize success.");
}
项目:Shop-for-JavaWeb
文件:ExportExcel.java
/**
* 初始化函数
* @param title 表格标题,传“空值”,表示无标题
* @param headerList 表头列表
*/
private void initialize(String title, List<String> headerList) {
this.wb = new SXSSFWorkbook(500);
this.sheet = wb.createSheet("Export");
this.styles = createStyles(wb);
// Create title
if (StringUtils.isNotBlank(title)){
Row titleRow = sheet.createRow(rownum++);
titleRow.setHeightInPoints(30);
Cell titleCell = titleRow.createCell(0);
titleCell.setCellStyle(styles.get("title"));
titleCell.setCellValue(title);
sheet.addMergedRegion(new CellRangeAddress(titleRow.getRowNum(),
titleRow.getRowNum(), titleRow.getRowNum(), headerList.size()-1));
}
// Create header
if (headerList == null){
throw new RuntimeException("headerList not null!");
}
Row headerRow = sheet.createRow(rownum++);
headerRow.setHeightInPoints(16);
for (int i = 0; i < headerList.size(); i++) {
Cell cell = headerRow.createCell(i);
cell.setCellStyle(styles.get("header"));
String[] ss = StringUtils.split(headerList.get(i), "**", 2);
if (ss.length==2){
cell.setCellValue(ss[0]);
Comment comment = this.sheet.createDrawingPatriarch().createCellComment(
new XSSFClientAnchor(0, 0, 0, 0, (short) 3, 3, (short) 5, 6));
comment.setString(new XSSFRichTextString(ss[1]));
cell.setCellComment(comment);
}else{
cell.setCellValue(headerList.get(i));
}
sheet.autoSizeColumn(i);
}
for (int i = 0; i < headerList.size(); i++) {
int colWidth = sheet.getColumnWidth(i)*2;
sheet.setColumnWidth(i, colWidth < 3000 ? 3000 : colWidth);
}
log.debug("Initialize success.");
}
项目:hadoopoffice
文件:MSExcelParser.java
@Override
public Object[] getNext() {
SpreadSheetCellDAO[] result=null;
// all sheets?
if (this.sheets==null) { // go on with all sheets
if (!nextAllSheets()) {
return result;
}
} else { // go on with specified sheets
if (!nextSpecificSheets()) {
return result;
}
}
// read row from the sheet currently to be processed
Sheet rSheet = this.currentWorkbook.getSheetAt(this.currentSheet);
Row rRow = rSheet.getRow(this.currentRow);
if (rRow==null) {
this.currentRow++;
return new SpreadSheetCellDAO[0]; // emtpy row
}
result = new SpreadSheetCellDAO[rRow.getLastCellNum()];
for (int i=0;i<rRow.getLastCellNum();i++) {
Cell currentCell=rRow.getCell(i);
if (currentCell==null) {
result[i]=null;
} else {
String formattedValue=useDataFormatter.formatCellValue(currentCell,this.formulaEvaluator);
String formula = "";
if (currentCell.getCellTypeEnum()==CellType.FORMULA) {
formula = currentCell.getCellFormula();
}
Comment currentCellComment = currentCell.getCellComment();
String comment = "";
if (currentCellComment!=null) {
comment = currentCellComment.getString().getString();
}
String address = currentCell.getAddress().toString();
String sheetName = currentCell.getSheet().getSheetName();
SpreadSheetCellDAO mySpreadSheetCellDAO = new SpreadSheetCellDAO(formattedValue,comment,formula,address,sheetName);
result[i]=mySpreadSheetCellDAO;
}
}
// increase rows
this.currentRow++;
return result;
}
项目:hadoopoffice
文件:MSExcelWriter.java
/**
* Add a cell to the current Workbook
*
* @param newDAO cell to add. If it is already existing an exception will be thrown. Note that the sheet name is sanitized using org.apache.poi.ss.util.WorkbookUtil.createSafeSheetName. The Cell address needs to be in A1 format. Either formula or formattedValue must be not null.
*
*/
@Override
public void write(Object newDAO) throws OfficeWriterException {
SpreadSheetCellDAO sscd = checkSpreadSheetCellDAO(newDAO);
String safeSheetName=WorkbookUtil.createSafeSheetName(sscd.getSheetName());
Sheet currentSheet=this.currentWorkbook.getSheet(safeSheetName);
if (currentSheet==null) {// create sheet if it does not exist yet
currentSheet=this.currentWorkbook.createSheet(safeSheetName);
if (!(safeSheetName.equals(sscd.getSheetName()))) {
LOG.warn("Sheetname modified from \""+sscd.getSheetName()+"\" to \""+safeSheetName+"\" to correspond to Excel conventions.");
}
// create drawing anchor (needed for comments...)
this.mappedDrawings.put(safeSheetName,currentSheet.createDrawingPatriarch());
}
// check if cell exist
CellAddress currentCA = new CellAddress(sscd.getAddress());
Row currentRow = currentSheet.getRow(currentCA.getRow());
if (currentRow==null) { // row does not exist? => create it
currentRow=currentSheet.createRow(currentCA.getRow());
}
Cell currentCell = currentRow.getCell(currentCA.getColumn());
if ((currentCell!=null) && (this.hasTemplate==false)) { // cell already exists and no template loaded ? => throw exception
throw new OfficeWriterException("Invalid cell specification: cell already exists at "+currentCA);
}
// create cell if no template is loaded or cell not available in template
if ((this.hasTemplate==false) || (currentCell==null)) {
currentCell=currentRow.createCell(currentCA.getColumn());
}
// set the values accordingly
if (!("".equals(sscd.getFormula()))) { // if formula exists then use formula
currentCell.setCellFormula(sscd.getFormula());
} else {
// else use formattedValue
currentCell.setCellValue(sscd.getFormattedValue());
}
// set comment
if ((sscd.getComment()!=null) && (!("".equals(sscd.getComment())))) {
/** the following operations are necessary to create comments **/
/** Define size of the comment window **/
ClientAnchor anchor = this.currentWorkbook.getCreationHelper().createClientAnchor();
anchor.setCol1(currentCell.getColumnIndex());
anchor.setCol2(currentCell.getColumnIndex()+this.howc.getCommentWidth());
anchor.setRow1(currentRow.getRowNum());
anchor.setRow2(currentRow.getRowNum()+this.howc.getCommentHeight());
/** create comment **/
Comment currentComment = mappedDrawings.get(safeSheetName).createCellComment(anchor);
currentComment.setString(this.currentWorkbook.getCreationHelper().createRichTextString(sscd.getComment()));
currentComment.setAuthor(this.howc.getCommentAuthor());
currentCell.setCellComment(currentComment);
}
}
项目:hadoopoffice
文件:MSExcelLowFootprintWriter.java
@Override
public void write(Object newDAO) throws OfficeWriterException {
SpreadSheetCellDAO sscd = MSExcelWriter.checkSpreadSheetCellDAO(newDAO);
String safeSheetName=WorkbookUtil.createSafeSheetName(sscd.getSheetName());
SXSSFSheet currentSheet=this.currentWorkbook.getSheet(safeSheetName);
if (currentSheet==null) {// create sheet if it does not exist yet
currentSheet=this.currentWorkbook.createSheet(safeSheetName);
if (!(safeSheetName.equals(sscd.getSheetName()))) {
LOG.warn("Sheetname modified from \""+sscd.getSheetName()+"\" to \""+safeSheetName+"\" to correspond to Excel conventions.");
}
// create drawing anchor (needed for comments...)
this.mappedDrawings.put(safeSheetName,currentSheet.createDrawingPatriarch());
}
// check if cell exist
CellAddress currentCA = new CellAddress(sscd.getAddress());
SXSSFRow currentRow = currentSheet.getRow(currentCA.getRow());
if (currentRow==null) { // row does not exist? => create it
currentRow=currentSheet.createRow(currentCA.getRow());
}
SXSSFCell currentCell = currentRow.getCell(currentCA.getColumn());
if ((currentCell!=null)) { // cell already exists and no template loaded ? => throw exception
throw new OfficeWriterException("Invalid cell specification: cell already exists at "+currentCA);
}
// create cell if no template is loaded or cell not available in template
currentCell=currentRow.createCell(currentCA.getColumn());
// set the values accordingly
if (!("".equals(sscd.getFormula()))) { // if formula exists then use formula
currentCell.setCellFormula(sscd.getFormula());
} else {
// else use formattedValue
currentCell.setCellValue(sscd.getFormattedValue());
}
// set comment
if ((sscd.getComment()!=null) && (!("".equals(sscd.getComment())))) {
/** the following operations are necessary to create comments **/
/** Define size of the comment window **/
ClientAnchor anchor = this.currentWorkbook.getCreationHelper().createClientAnchor();
anchor.setCol1(currentCell.getColumnIndex());
anchor.setCol2(currentCell.getColumnIndex()+this.howc.getCommentWidth());
anchor.setRow1(currentRow.getRowNum());
anchor.setRow2(currentRow.getRowNum()+this.howc.getCommentHeight());
/** create comment **/
Comment currentComment = mappedDrawings.get(safeSheetName).createCellComment(anchor);
currentComment.setString(this.currentWorkbook.getCreationHelper().createRichTextString(sscd.getComment()));
currentComment.setAuthor(this.howc.getCommentAuthor());
currentCell.setCellComment(currentComment);
}
}
项目:embulk-parser-poi_excel
文件:PoiExcelCellCommentVisitor.java
@Override
protected Comment getAttributeSource(PoiExcelColumnBean bean, Cell cell) {
return cell.getCellComment();
}
项目:embulk-parser-poi_excel
文件:PoiExcelCellCommentVisitor.java
@Override
protected Map<String, AttributeSupplier<Comment>> getAttributeSupplierMap() {
return SUPPLIER_MAP;
}
项目:embulk-parser-poi_excel
文件:PoiExcelCellCommentVisitor.java
@Override
public Object get(Column column, Cell cell, Comment comment) {
return comment.getAuthor();
}
项目:embulk-parser-poi_excel
文件:PoiExcelCellCommentVisitor.java
@Override
public Object get(Column column, Cell cell, Comment comment) {
return (long) comment.getColumn();
}
项目:embulk-parser-poi_excel
文件:PoiExcelCellCommentVisitor.java
@Override
public Object get(Column column, Cell cell, Comment comment) {
return (long) comment.getRow();
}
项目:embulk-parser-poi_excel
文件:PoiExcelCellCommentVisitor.java
@Override
public Object get(Column column, Cell cell, Comment comment) {
return comment.isVisible();
}
项目:embulk-parser-poi_excel
文件:PoiExcelCellCommentVisitor.java
@Override
public Object get(Column column, Cell cell, Comment comment) {
RichTextString rich = comment.getString();
return rich.getString();
}
项目:embulk-parser-poi_excel
文件:PoiExcelCellCommentVisitor.java
@Override
public Object get(Column column, Cell cell, Comment comment) {
return getClientAnchorValue(column, cell, comment, null);
}
项目:embulk-parser-poi_excel
文件:PoiExcelCellCommentVisitor.java
@Override
public Object get(Column column, Cell cell, Comment comment) {
return getClientAnchorValue(column, cell, comment, key);
}
项目:embulk-parser-poi_excel
文件:PoiExcelCellCommentVisitor.java
final Object getClientAnchorValue(Column column, Cell cell, Comment comment, String key) {
ClientAnchor anchor = comment.getClientAnchor();
PoiExcelVisitorFactory factory = visitorValue.getVisitorFactory();
PoiExcelClientAnchorVisitor delegator = factory.getPoiExcelClientAnchorVisitor();
return delegator.getClientAnchorValue(column, cell, anchor, key);
}
项目:openbd-core
文件:SpreadsheetSetCellComment.java
public cfData execute( cfSession _session, List<cfData> parameters ) throws cfmRunTimeException {
if ( parameters.get(2).getDataType() != cfData.CFSTRUCTDATA )
throwException(_session, "parameter must be of type structure");
cfSpreadSheetData spreadsheet = null;
cfStructData commentS = null;
int rowNo, columnNo;
/*
* Collect up the parameters
*/
spreadsheet = (cfSpreadSheetData)parameters.get(3);
commentS = (cfStructData)parameters.get(2);
rowNo = parameters.get(1).getInt() - 1;
columnNo = parameters.get(0).getInt() - 1;
if ( rowNo < 0 )
throwException(_session, "row must be 1 or greater (" + rowNo + ")");
if ( columnNo < 0 )
throwException(_session, "column must be 1 or greater (" + columnNo + ")");
/*
* Perform the insertion
*/
Sheet sheet = spreadsheet.getActiveSheet();
Row row = sheet.getRow( rowNo );
if ( row == null )
row = sheet.createRow( rowNo );
Cell cell = row.getCell( columnNo );
if ( cell == null )
cell = row.createCell( columnNo );
// Create the anchor
HSSFClientAnchor clientAnchor = new HSSFClientAnchor();
if ( commentS.containsKey("anchor") ){
String[] anchor = commentS.getData("anchor").getString().split(",");
if ( anchor.length != 4 )
throwException(_session,"Invalid 'anchor' attribute, should be 4 numbers");
clientAnchor.setRow1( Integer.valueOf( anchor[0] ) - 1 );
clientAnchor.setCol1( Integer.valueOf( anchor[1] ) - 1 );
clientAnchor.setRow2( Integer.valueOf( anchor[2] ) - 1 );
clientAnchor.setCol2( Integer.valueOf( anchor[3] ) - 1 );
}else{
clientAnchor.setRow1( rowNo );
clientAnchor.setCol1( columnNo );
clientAnchor.setRow2( rowNo + 2 );
clientAnchor.setCol2( columnNo + 2 );
}
// Create the comment
Comment comment = spreadsheet.getActiveSheet().createDrawingPatriarch().createCellComment(clientAnchor);
if ( commentS.containsKey("author") ){
comment.setAuthor( commentS.getData("author").getString() );
}
if ( commentS.containsKey("visible") ){
comment.setVisible( commentS.getData("visible").getBoolean() );
}
if ( commentS.containsKey("comment") ){
HSSFRichTextString richText = new HSSFRichTextString( commentS.getData("comment").getString() );
try {
richText.applyFont( SpreadSheetFormatOptions.createCommentFont(spreadsheet.getWorkBook(), commentS) );
} catch (Exception e) {
throwException( _session, e.getMessage() );
}
comment.setString( richText );
}
cell.setCellComment( comment );
return cfBooleanData.TRUE;
}
项目:olat
文件:ExcelOOXMLDocument.java
private void extractContent(final StringBuilder buffy, final XSSFWorkbook document) {
for (int i = 0; i < document.getNumberOfSheets(); i++) {
final XSSFSheet sheet = document.getSheetAt(i);
buffy.append(document.getSheetName(i)).append(' ');
// Header(s), if present
extractHeaderFooter(buffy, sheet.getFirstHeader());
extractHeaderFooter(buffy, sheet.getOddHeader());
extractHeaderFooter(buffy, sheet.getEvenHeader());
// Rows and cells
for (final Object rawR : sheet) {
final Row row = (Row) rawR;
for (final Iterator<Cell> ri = row.cellIterator(); ri.hasNext();) {
final Cell cell = ri.next();
if (cell.getCellType() == Cell.CELL_TYPE_FORMULA || cell.getCellType() == Cell.CELL_TYPE_STRING) {
buffy.append(cell.getRichStringCellValue().getString()).append(' ');
} else {
final XSSFCell xc = (XSSFCell) cell;
final String rawValue = xc.getRawValue();
if (rawValue != null) {
buffy.append(rawValue).append(' ');
}
}
// Output the comment in the same cell as the content
final Comment comment = cell.getCellComment();
if (comment != null) {
buffy.append(comment.getString().getString()).append(' ');
}
}
}
// Finally footer(s), if present
extractHeaderFooter(buffy, sheet.getFirstFooter());
extractHeaderFooter(buffy, sheet.getOddFooter());
extractHeaderFooter(buffy, sheet.getEvenFooter());
}
}
项目:excella-core
文件:CellClone.java
public Comment getCellComment() {
return cellComment;
}
项目:excella-core
文件:CellClone.java
public void setCellComment(Comment comment) {
throw new IllegalStateException("CellClone is not support setCellComment(Comment comment).");
}
项目:birt
文件:FilteredSheet.java
public Comment getCellComment(int row, int column) {
return sheet.getCellComment(row, column);
}
项目:excel-streaming-reader
文件:StreamingSheet.java
/**
* Not supported
*/
@Override
public Comment getCellComment(CellAddress cellAddress) {
throw new UnsupportedOperationException();
}
项目:excel-streaming-reader
文件:StreamingSheet.java
/**
* Not supported
*/
@Override
public Map<CellAddress, ? extends Comment> getCellComments() {
throw new UnsupportedOperationException();
}
项目:excel-streaming-reader
文件:StreamingCell.java
/**
* Not supported
*/
@Override
public void setCellComment(Comment comment) {
throw new NotSupportedException();
}
项目:excel-streaming-reader
文件:StreamingCell.java
/**
* Not supported
*/
@Override
public Comment getCellComment() {
throw new NotSupportedException();
}
项目:xlsmapper
文件:CellCommentStore.java
/**
* 保持している情報を元に、シートのセルにコメントを設定する。
* @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;
}
项目:enerko-reports2
文件:CommentDefinition.java
public CommentDefinition(final Comment comment) {
this(comment.getString().getString(), comment.getAuthor(), comment.getColumn(), comment.getRow(), -1, -1, comment.isVisible());
}
项目:Gargoyle
文件:ExcelUtil.java
/**
* 특정셀에 코멘트를 추가한다.
*
* @param sheet
* @param cell
* @param commentText
* @return
*/
public static void addComment(Sheet sheet, Cell cell, String commentText) {
XSSFDrawing patr = (XSSFDrawing) sheet.createDrawingPatriarch();
Comment comment = patr.createCellComment(new XSSFClientAnchor(0, 0, 0, 0, (short) 4, 2, (short) 6, 5));
comment.setString(new XSSFRichTextString(commentText));
cell.setCellComment(comment);
}