Created attachment 23648 [details] Attachment for the bug XSSFComment comment = sheet.createComment() and then calling cell.setCellComment(comment); corrupts the workbook. Opening the workbook gives the following error: Removed Records: Comments from /xl/comments1.xml part (Comments)
the problem should be fixed in r884918. Was the attached template created by POI? If so, please re-create it using the latest build from trunk. Your template contains comments not having visual properties that are stored in the vmlDrawing.vml part. r884918 fixed this and some other bugs. Yegor
Now setting comment on a xlsx file works!
Hi, I have tried creating comments in the excel file, using below code ClientAnchor anchor = ch.createClientAnchor(); Comment comment = drawing.createCellComment(anchor); comment.setString(ch.createRichTextString(alias)); cell.setCellComment(comment); after writing the xls and opening the file it gives error "File error data may have been lost" and opens the file In the file, content is anchored to first cell as well as minimized which you need to expand to see the comment. Rajeev
Reopening the bug.
Rajeev, Please attach sample code to reproduce the problem. The code snippet you posted is not enough. If your code uses a template then attach it as well. Which version of POI are you using? Make sure it is POI-3.6 or 3.7-SNAPSHOT. Yegor
yes I am using 3.6 and without any template below is the code snippet ClientAnchor anchor = ch.createClientAnchor(); anchor.setCol1(6+i); anchor.setRow1(4+i); anchor.setCol2(12+i); anchor.setRow2(13+i); anchor.setDx1(i*4); anchor.setDy1(i*4); anchor.setDx2(i*4); anchor.setDy2(i*4); Comment comment = drawing.createCellComment(anchor); comment.setString(ch.createRichTextString(alias)); comment.setColumn(i); comment.setRow(0); cell.setCellComment(comment); Setting co-ordinates solved the anchoring problem but still i guess the same old error Opening the workbook gives the following error: Removed Records: Comments from /xl/comments1.xml part (Comments) Not sure whether I am missing anything.
changing the status after providing asked info
Rajeev, I can't reproduce the problem with the current trunk. The following code snippet works fine and produces readable output: public static void main(String[] args) throws Exception { Workbook wb = new XSSFWorkbook(); Sheet sh = wb.createSheet(); int i = 0; Cell cell = sh.createRow(0).createCell(i); CreationHelper ch = wb.getCreationHelper(); Drawing drawing = sh.createDrawingPatriarch(); ClientAnchor anchor = ch.createClientAnchor(); anchor.setCol1(6+i); anchor.setRow1(4+i); anchor.setCol2(12+i); anchor.setRow2(13+i); anchor.setDx1(i*4); anchor.setDy1(i*4); anchor.setDx2(i*4); anchor.setDy2(i*4); Comment comment = drawing.createCellComment(anchor); comment.setString(ch.createRichTextString("Testing 47188")); comment.setColumn(i); comment.setRow(0); cell.setCellComment(comment); FileOutputStream out = new FileOutputStream("/temp/47188.xlsx"); wb.write(out); out.close(); } Try the latest build from trunk. Nightly builds can be downloaded from http://encore.torchbox.com/poi-svn-build/. If the problem persists, please attach full sample code to reproduce, ideally a junit test case. Yegor
I believe this is now fixed, please re-open if the problem remains with a recent svn nightly build / recent release, and include details of how to replicate the problem