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 2014/01/16 11:04:58 UTC

[Bug 56017] New: Shifting rows with comment result - Unreadable content error and comment deletion

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

            Bug ID: 56017
           Summary: Shifting rows with comment result - Unreadable content
                    error and comment deletion
           Product: POI
           Version: 3.9
          Hardware: PC
            Status: NEW
          Severity: major
          Priority: P2
         Component: XSSF
          Assignee: dev@poi.apache.org
          Reporter: yevsjunk@gmail.com

If I try to shiftrows that contains comments nad open excel document in Excel I
get a popup warning Message "Unreadable content..." that says that comments
were deleted.

How to reproduce:
Create new Excel 2007 Document, in first cell (A1) add comment (any text).

Run code:

FileInputStream inputStream = null;
FileOutputStream outputStream = null;
XSSFWorkbook book = null;

try {
    inputStream = new FileInputStream("c://1//Test.xlsx");
    book = new XSSFWorkbook(inputStream);

    XSSFSheet sheet = book.getSheetAt(0);

    sheet.shiftRows(0, 1, 1);

    outputStream = new FileOutputStream("c://1//Test.xlsx");
    book.write(outputStream);
    outputStream.close();

}

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


[Bug 56017] Shifting rows with comment result - Unreadable content error and comment deletion

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

--- Comment #8 from Mikalai Zhudro <me...@gmail.com> ---
Created attachment 32431
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=32431&action=edit
Broken excel 2010 file

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


[Bug 56017] Shifting rows with comment result - Unreadable content error and comment deletion

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

--- Comment #1 from yevsjunk@gmail.com ---
Created attachment 31215
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=31215&action=edit
Test file - before running the code

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


[Bug 56017] Shifting rows with comment result - Unreadable content error and comment deletion

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

--- Comment #9 from Mikalai Zhudro <me...@gmail.com> ---
I was able to reproduce this bug with Excel 2010. (poi 3.11 Final)
My further investigation shows that problem lies in following code:

XSSFSheet.java:2567

if(sheetComments != null){
                //TODO shift Note's anchor in the associated
/xl/drawing/vmlDrawings#.vml
                CTCommentList lst =
sheetComments.getCTComments().getCommentList();
                for (CTComment comment : lst.getCommentArray()) {
                    String oldRef = comment.getRef();
                    CellReference ref = new CellReference(oldRef);
                    if(ref.getRow() == rownum){
                        ref = new CellReference(rownum + n, ref.getCol());
                        comment.setRef(ref.formatAsString());
                        sheetComments.referenceUpdated(oldRef, comment);
                    }
                }
            }
I looked at /xl/drawing/vmlDrawings#.vml and note's anchor was not shifted.
So I updated this file manually and was able to open excel file without
problem.
Can somebody implement this TODO??

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


[Bug 56017] Shifting rows with comment result - Unreadable content error and comment deletion

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

j.brauge@qualiac.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |NEEDINFO
            Version|3.9                         |3.10

--- Comment #4 from j.brauge@qualiac.com ---
This bug persists in 3.10 final release and 3.11 dev.
Is there a target release for a fix ?
Best regards.

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


[Bug 56017] Shifting rows with comment result - Unreadable content error and comment deletion

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

Mikalai Zhudro <me...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |merlusha@gmail.com

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


[Bug 56017] Shifting rows with comment result - Unreadable content error and comment deletion

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

--- Comment #6 from happyhuman <da...@gmail.com> ---
In: org.apache.poi.xssf.usermodel.XSSFSheet

I believe line:
2451            if(rownum < startRow || rownum > endRow) continue;

Should be above:
2439            if(sheetComments != null){


The exception I was getting started here:
2445                        ref = new CellReference(rownum + n, ref.getCol());

Looks as though it's trying to update the comments table with the new cell
references after the rows are shifted, but the iterator is over all rows and
the check for the shifted range is after this block. Therefore, an attempt
could be made for a negative row value. I would assume if you do not get an
exception the workbook may corrupt. Fixed the issue for me anyway and hope it
helps.

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


[Bug 56017] Shifting rows with comment result - Unreadable content error and comment deletion

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

--- Comment #5 from happyhuman <da...@gmail.com> ---
In: org.apache.poi.xssf.usermodel.XSSFSheet

I believe line:
2451            if(rownum < startRow || rownum > endRow) continue;

Should be above:
2439            if(sheetComments != null){


The exception I was getting started here:
2445                        ref = new CellReference(rownum + n, ref.getCol());

Looks as though it's trying to update the comments table with the new cell
references after the rows are shifted, but the iterator is over all rows and
the check for the shifted range is after this block. Therefore, an attempt
could be made for a negative row value. Fixed the issue for me anyway and hope
it helps.

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


[Bug 56017] Shifting rows with comment result - Unreadable content error and comment deletion

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

Dominik Stadler <do...@gmx.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 OS|                            |All

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


[Bug 56017] Shifting rows with comment result - Unreadable content error and comment deletion

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

--- Comment #7 from m_and_m <ma...@gmail.com> ---
In the shiftRows method when it adjusts comments/rowheight it does all rows(!)
in the current sheet. It doesn't always cause exception or error when opening
xlsx, but always makes worse all of comments.
For example:
if I call it: sheet.shiftRows(3, 4, 20, true, false);
then it shift all comments on 0, 1, and 2 rows too instead of leave in peace.

It's a simply, but annoying bug. Please fix it asap!

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


[Bug 56017] Shifting rows with comment result - Unreadable content error and comment deletion

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

Mikalai Zhudro <me...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
            Version|3.10-FINAL                  |3.11-FINAL

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


[Bug 56017] Shifting rows with comment result - Unreadable content error and comment deletion

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

--- Comment #2 from Dominik Stadler <do...@gmx.at> ---
I have added a test-case in r1563587 and r1563588 which runs this, I fixed a
problem with comment-refs which only affected the in-memory state of comments,
as I don't have a Windows-machine with Excel at hand to verify/reproduce the
problem, so I am not sure if it is fixed in latest trunk or not...

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


[Bug 56017] Shifting rows with comment result - Unreadable content error and comment deletion

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

--- Comment #3 from yevsjunk@gmail.com ---
Thanks, I will test it latter.
Meanwhile, I made some work around in shiftRows method  of XSSFSheet...

Anyway, will the next POI release include the fix to the issue?

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