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~~~~
Hi, Attach please the source .xls file you work with Regards, Evgeniy
Created attachment 29305 [details] this xls can remove all comments this xls can remove all comments
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,
(In reply to comment #1) I added 2 xls files, thanks > Hi, > > Attach please the source .xls file you work with > > Regards, Evgeniy
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
Created attachment 29312 [details] Code & Run Result oh no..My Code Can't Pass~~~ why? I use poi-3.8-20120326.jar thx
Hi Virgil.Chen You can download the latest build from this link https://builds.apache.org/job/POI/lastSuccessfulBuild/artifact/build/dist/ Regards, Evgeniy
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
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
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
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