Hi,

I cannot add comments to an xlsx spreadsheet. I closely followed the examples but I cannot see what what I'm doing wrong.

import java.io.FileOutputStream;
import java.io.IOException;

import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Comment;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.xssf.usermodel.XSSFRichTextString;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;

public class TestComment {
        public static void main(String[] args) throws IOException {
                XSSFWorkbook wb = new XSSFWorkbook();

    XSSFSheet sheet1 = wb.createSheet("Sheet1");

    Row row = sheet1.createRow((short)1);
    Cell cell = row.createCell(1);
    cell.setCellValue(1);

    Comment c1 = sheet1.createComment();
    c1.setAuthor("Author 1");
    c1.setString(new XSSFRichTextString("Comment 1"));
    cell.setCellComment(c1);

    Comment c2 = sheet1.createComment();
    c2.setAuthor("Author 2");
    c2.setString(new XSSFRichTextString("Second Comment"));
    c2.setRow(2);
    c2.setColumn((short)2);


FileOutputStream fileOut = new FileOutputStream("C:/Temp/workbook.xlsx");
    wb.write(fileOut);
    fileOut.close();

    System.out.println("Done!");

        }
}


The comments don't show up in the file. Am I doing something wrong? I also tried to use the examples from http://poi.apache.org/spreadsheet/quick-guide.html#CellComments but I get the same result.

I'm using Windows XP, and Excel 2007.

Thank you for any suggestions.

Adrian

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to