You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Arimitsu Ishii <is...@infoteria.com> on 2013/03/12 10:12:45 UTC

How to add comments over 1024 on HSSF.

Hello All,

I want to add comments to over1024 cells.
but I cannot add comments.

so, I checked source HSSFShape.java setShapeId() method.
CommonObjectDataSubRecord cod = (CommonObjectDataSubRecord)
_objRecord.getSubRecords().get(0);
cod.setObjectId((short) (shapeId%1024));
The maximum ObjectId of this function can be set is 1023.

The HSSF Sheet can not add a comment more than 1024.
It's specification?


I'm using POI 3.9.

try {
InputStream is= new FileInputStream("test.xls");
Workbook workbook = WorkbookFactory.create(is);
is.close();
Sheet sheet = workbook.getSheet("Sheet1");

CreationHelper ch = workbook.getCreationHelper();
ClientAnchor anchor = ch.createClientAnchor();
Drawing drawing = sheet.createDrawingPatriarch();

int z=0;
for (int r=1; r<201; r++) {
Row row = sheet.getRow(r);
for (int c=1; c<11; c++) {
Cell cell = row.getCell(c);
if (cell == null) {
cell = row.createCell(c);
}
Comment newComment = drawing.createCellComment(anchor);
newComment.setString(ch.createRichTextString("comment"));
cell.setCellComment(newComment);
}
}

FileOutputStream os = new FileOutputStream("res.xls");
workbook.write(os);
os.close();
} catch (Exception e) {
}

Thanks,

Arimitsu

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org