You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2011/02/26 00:49:25 UTC

DO NOT REPLY [Bug 50833] New: workbook.write(outputstream) corrupts cell comments for protected workbooks

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

           Summary: workbook.write(outputstream) corrupts cell comments
                    for protected workbooks
           Product: POI
           Version: 3.7
          Platform: PC
            Status: NEW
          Severity: major
          Priority: P2
         Component: HSSF
        AssignedTo: dev@poi.apache.org
        ReportedBy: robertl@jlab.org


Created an attachment (id=26695)
 --> (https://issues.apache.org/bugzilla/attachment.cgi?id=26695)
sample xls workbook to use with code provided in description

If you have a workbook that is protected and you open the it and write it to an
output stream, all comments in the workbook end up corrupted.
Attached is a sample workbook (protected password is "password") to use with
the following code:

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);
        workbook.write(new FileOutputStream(new File("Book1_copy.xls")));
    }
}

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 50833] workbook.write(outputstream) corrupts cell comments for protected workbooks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50833

--- Comment #7 from Bobby Lawrence <ro...@jlab.org> 2011-03-04 16:40:16 EST ---
I'm sorry - my comment was incorrect.
The file was created in MS Excel 2010.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 50833] workbook.write(outputstream) corrupts cell comments for protected workbooks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50833

--- Comment #2 from Bobby Lawrence <ro...@jlab.org> 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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 50833] workbook.write(outputstream) corrupts cell comments for protected workbooks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50833

Nick Burch <ni...@alfresco.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO
         OS/Version|                            |All

--- Comment #1 from Nick Burch <ni...@alfresco.com> 2011-02-26 16:44:11 EST ---
When you first read the file in, can POI see all your comments fine?

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?)

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 50833] workbook.write(outputstream) corrupts cell comments for protected workbooks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50833

--- Comment #4 from Bobby Lawrence <ro...@jlab.org> 2011-03-04 16:12:56 EST ---
The example spreadsheet I uploaded to the bug was generated with Microsoft
Office 2007 and saved as an Excel 97-2003 format.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 50833] workbook.write(outputstream) corrupts cell comments for protected workbooks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50833

--- Comment #3 from Nick Burch <ni...@alfresco.com> 2011-03-04 16:05:04 EST ---
Everyone here are volunteers, and there are lots of people with bugs and not
nearly so many people producing patches to fix them. Plus, you know your
problem much better than we do....

In terms of your problem, OpenOffice can open the poi written file just fine,
so it looks like we're not doing too much wrong. 

However, your original source file seems to be problematic. When I try to run
it through BiffViewer, BiffViewer blows up. When I try to run it through the
beta Microsoft validator, that claims not to recognise the file. So, I think
there's something odd about your source file.

How was the file generated?

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 50833] workbook.write(outputstream) corrupts cell comments for protected workbooks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50833

--- Comment #5 from David Fisher <df...@jmlafferty.com> 2011-03-04 16:37:13 EST ---
I opened the original file in Mac Excel 2008 and 2011. It opened fine. I did
notice that the comment had a different vertical position in the two versions.

In 2008 it was slightly above the top of the top row.

in 2011 it was slightly below the top of the top row.

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


DO NOT REPLY [Bug 50833] workbook.write(outputstream) corrupts cell comments for protected workbooks

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=50833

--- Comment #6 from Nick Burch <ni...@alfresco.com> 2011-03-04 16:39:11 EST ---
Hmm, so it ought to be fine then.

BiffViewer is blowing up though with:

java.lang.IllegalArgumentException: Name is too long:
k~�����>�`�8��<()�~i:�
2Å$a�Ճp����۵���6��Ӕ��m.����#p1tP>��=� ��ȉa��y��Q1���8�YZwbN�!{��
    at
org.apache.poi.hssf.record.WriteAccessRecord.setUsername(WriteAccessRecord.java:104)
    at
org.apache.poi.hssf.record.WriteAccessRecord.<init>(WriteAccessRecord.java:72)
    at org.apache.poi.hssf.dev.BiffViewer.createRecord(BiffViewer.java:254)
    at org.apache.poi.hssf.dev.BiffViewer.createRecords(BiffViewer.java:86)
    at org.apache.poi.hssf.dev.BiffViewer.main(BiffViewer.java:416)

Until we get that fixed, we probably can't figure out what's being changed by
the read/write from POI to know what it might be that excel doesn't like...

-- 
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: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org