Bug 53799

Summary: Can't Remove Comments when the number of comments more than 54
Product: POI Reporter: Virgil.Chen <tony810428>
Component: HSSFAssignee: POI Developers List <dev>
Status: RESOLVED LATER    
Severity: normal    
Priority: P2    
Version: 3.8-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows XP   
Attachments: this xls can remove all comments
this xls can't remove all comments
Code & Run Result

Description Virgil.Chen 2012-08-30 04:39:11 UTC
I wanted to remove all comments in my workbook, but exception was thrown.

my code as follow,

-------------
for (int i = sheet.getLastRowNum() ; i >=0 ; i --) {
    Row row = sheet.getRow(i) ;
	
    if (row == null) {
        continue ;
    }
	
    for (int j = row.getLastCellNum() ; j >= 0 ; j --) {
        org.apache.poi.ss.usermodel.Cell c = row.getCell(j) ;
    
        if (c == null) {
    	    continue ;
        }

        c.removeCellComment() ;
        row.removeCell(c) ;
    }
	
    sheet.removeRow(row) ;
}
--------------------


when the number of comments in .xls more than 60 or more, will throw exception as follow

-----------------------
//HSSFCell, line is 1065
throw new IllegalStateException("Found the wrong records before the TextObjectRecord, can't remove comment");
----------------------

is any firend can help? thanks~~~~
Comment 1 Evgeniy Berlog 2012-08-30 07:38:30 UTC
Hi,

Attach please the source .xls file you work with

Regards, Evgeniy
Comment 2 Virgil.Chen 2012-08-30 12:59:40 UTC
Created attachment 29305 [details]
this xls can remove all comments

this xls can remove all comments
Comment 3 Virgil.Chen 2012-08-30 13:02:26 UTC
Created attachment 29306 [details]
this xls can't remove all comments

I added 2 rows to this xls base on before xls, and this xls can't remove all comments,
Comment 4 Virgil.Chen 2012-08-30 13:04:41 UTC
(In reply to comment #1)
I added 2 xls files, thanks

> Hi,
> 
> Attach please the source .xls file you work with
> 
> Regards, Evgeniy
Comment 5 Evgeniy Berlog 2012-08-30 19:44:42 UTC
I've executed your code with both of your input files successully.
Please, say what version of POI do you use.

I used POI trunk latest build. You can see download links on http://poi.apache.org/
or build yourself from SVN trunk, see http://poi.apache.org/subversion.html. 

Regards, Evgeniy
Comment 6 Virgil.Chen 2012-08-31 12:56:40 UTC
Created attachment 29312 [details]
Code & Run Result

oh no..My Code Can't Pass~~~ why?
I use poi-3.8-20120326.jar
thx
Comment 7 Evgeniy Berlog 2012-08-31 19:31:39 UTC
Hi Virgil.Chen

You can download the latest build from this link https://builds.apache.org/job/POI/lastSuccessfulBuild/artifact/build/dist/

Regards, Evgeniy
Comment 8 Virgil.Chen 2012-09-02 01:45:22 UTC
Dear Evgeniy,

It's very strange~~ ah ha~~

I download poi-bin-3.9-beta1-20120829.tar.gz to run my test case, but get the same Error~~

any suggestion? JDK Version? OS ?

thank you very much~~



Regards, Virgil

(In reply to comment #7)
> Hi Virgil.Chen
> 
> You can download the latest build from this link
> https://builds.apache.org/job/POI/lastSuccessfulBuild/artifact/build/dist/
> 
> Regards, Evgeniy
Comment 9 Evgeniy Berlog 2012-09-02 08:59:29 UTC
Hi Virgil,

I think that OS or jdk version don't affect the result in this case.
I've checked your code with POI 3.8 and this bug really appeared.

Probably you have two POI libraries in classpath. Please check your configuration one more time and if you find old POI library in your classpath just remove it.

Regards, Evgeniy

(In reply to comment #8)
> Dear Evgeniy,
> 
> It's very strange~~ ah ha~~
> 
> I download poi-bin-3.9-beta1-20120829.tar.gz to run my test case, but get
> the same Error~~
> 
> any suggestion? JDK Version? OS ?
> 
> thank you very much~~
> 
> 
> 
> Regards, Virgil
> 
> (In reply to comment #7)
> > Hi Virgil.Chen
> > 
> > You can download the latest build from this link
> > https://builds.apache.org/job/POI/lastSuccessfulBuild/artifact/build/dist/
> > 
> > Regards, Evgeniy
Comment 10 Virgil.Chen 2012-09-02 10:41:03 UTC
Dear Evgeniy,

I created a new project and ran the test case under 3.9-jar, it's passed,
you are right, thank you  very much.

I will take the other way to my project so as to avoid it, and waiting next version release.

anyway, thanks~~~





(In reply to comment #9)
> Hi Virgil,
> 
> I think that OS or jdk version don't affect the result in this case.
> I've checked your code with POI 3.8 and this bug really appeared.
> 
> Probably you have two POI libraries in classpath. Please check your
> configuration one more time and if you find old POI library in your
> classpath just remove it.
> 
> Regards, Evgeniy
> 
> (In reply to comment #8)
> > Dear Evgeniy,
> > 
> > It's very strange~~ ah ha~~
> > 
> > I download poi-bin-3.9-beta1-20120829.tar.gz to run my test case, but get
> > the same Error~~
> > 
> > any suggestion? JDK Version? OS ?
> > 
> > thank you very much~~
> > 
> > 
> > 
> > Regards, Virgil
> > 
> > (In reply to comment #7)
> > > Hi Virgil.Chen
> > > 
> > > You can download the latest build from this link
> > > https://builds.apache.org/job/POI/lastSuccessfulBuild/artifact/build/dist/
> > > 
> > > Regards, Evgeniy
Comment 11 Evgeniy Berlog 2012-09-02 12:36:04 UTC
Virgil,

I'm glad that I helped you. Good luck in your project.

Regards, Evgeniy

(In reply to comment #10)
> Dear Evgeniy,
> 
> I created a new project and ran the test case under 3.9-jar, it's passed,
> you are right, thank you  very much.
> 
> I will take the other way to my project so as to avoid it, and waiting next
> version release.
> 
> anyway, thanks~~~
> 
> 
> 
> 
> 
> (In reply to comment #9)
> > Hi Virgil,
> > 
> > I think that OS or jdk version don't affect the result in this case.
> > I've checked your code with POI 3.8 and this bug really appeared.
> > 
> > Probably you have two POI libraries in classpath. Please check your
> > configuration one more time and if you find old POI library in your
> > classpath just remove it.
> > 
> > Regards, Evgeniy
> > 
> > (In reply to comment #8)
> > > Dear Evgeniy,
> > > 
> > > It's very strange~~ ah ha~~
> > > 
> > > I download poi-bin-3.9-beta1-20120829.tar.gz to run my test case, but get
> > > the same Error~~
> > > 
> > > any suggestion? JDK Version? OS ?
> > > 
> > > thank you very much~~
> > > 
> > > 
> > > 
> > > Regards, Virgil
> > > 
> > > (In reply to comment #7)
> > > > Hi Virgil.Chen
> > > > 
> > > > You can download the latest build from this link
> > > > https://builds.apache.org/job/POI/lastSuccessfulBuild/artifact/build/dist/
> > > > 
> > > > Regards, Evgeniy