https://issues.apache.org/bugzilla/show_bug.cgi?id=50833

--- Comment #2 from Bobby Lawrence <[email protected]> 2011-02-28 10:05:06 EST 
---
Not quite sure why you need me to answer these questions as the bug is easily
reproduce-able using the provided code and any Excel doc...
Don't you guys verify these bugs?
I assume that if I don't answer them, this bug report will probably be
dismissed because no one takes the initiative to try to answer the questions
themselves so I will...

Q: When you first read the file in, can POI see all your comments fine?
A: Yes

Q: After writing the file out, can POI read it back in and still see the
comments?
(i.e. are they corrupted for both POI and Excel, or just for Excel?)
A: POI can read the file back in and still see the comments.



Here is a modified version of my original test code that answers your
questions:


import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;

public class CommentTest {
    public static void main(String[] args) throws Exception {
        File file = new File("Book1.xls");
        FileInputStream fileInputStream = new FileInputStream(file);
        HSSFWorkbook workbook = new HSSFWorkbook(fileInputStream);
        System.out.println(file.getName() + " sheet1.cellA1 comment=" +
workbook.getSheetAt(0).getRow(0).getCell(0).getCellComment().getString());
        File newFile = new File("Book1_copy.xls");
        workbook.write(new FileOutputStream(newFile));
        fileInputStream = new FileInputStream(newFile);
        workbook = new HSSFWorkbook(fileInputStream);
        System.out.println(newFile.getName() + " sheet1.cellA1 comment=" +
workbook.getSheetAt(0).getRow(0).getCell(0).getCellComment().getString());
    }
}

-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

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

Reply via email to