import java.io.*; import org.apache.poi.hssf.usermodel.*; // IN this test file i have created 3 cells and 2 comment objects and have not used one comment object // The comment object which is not used is being displayed in excel file in the first cell which is total disaster... public class Test3 { public static void main(String[] args) throws IOException { HSSFWorkbook wb=new HSSFWorkbook(); HSSFSheet finalsheet=wb.createSheet(); HSSFCell cell1=finalsheet.createRow(0).createCell((short) 5); HSSFCell cell2=finalsheet.createRow(0).createCell((short) 6); HSSFCell cell3=finalsheet.createRow(1).createCell((short) 6); HSSFPatriarch patr = finalsheet.createDrawingPatriarch(); HSSFComment comment1 = patr.createComment(new HSSFClientAnchor(0, 100, 0, 0, (short)4, 2, (short) 6, 5)); comment1.setString(new HSSFRichTextString("help me 1")); comment1.setAuthor("SUMIT"); HSSFComment comment2 = patr.createComment(new HSSFClientAnchor(0, 100, 0, 0, (short)4, 2, (short) 6, 5)); comment2.setString(new HSSFRichTextString("help me 2")); comment2.setAuthor("SUMIT"); cell1.setCellComment(comment1); cell2.setCellComment(comment1); cell3.setCellComment(comment1); ByteArrayOutputStream out= new ByteArrayOutputStream(); wb.write(out); out.close(); HSSFWorkbook wbNew=new HSSFWorkbook(); wbNew = new HSSFWorkbook(new ByteArrayInputStream(out.toByteArray())); FileOutputStream out1 = new FileOutputStream("workbook3.xls"); wbNew.write(out1); out1.close(); System.out.println("end of test"); } }