Bug 53144

Summary: First comment not cloned after cloneSheet()
Product: POI Reporter: Arimitsu <ishii>
Component: HSSFAssignee: POI Developers List <dev>
Severity: normal    
Priority: P2    
Version: 3.8-FINAL   
Target Milestone: ---   
Hardware: PC   
OS: Windows Vista   
Attachments: Test output file. res.xls
A file for test input

Description Arimitsu 2012-04-25 07:05:55 UTC
Created attachment 28674 [details]
Test output file. res.xls

A cell's comment is not cloned.
The comment is a comment processed by the 1st.(May be)

public static void test() {
 try {
  InputStream is= new FileInputStream("test.xls");	
  Workbook workbook = WorkbookFactory.create(is);

  Sheet sheet = workbook.cloneSheet(workbook.getSheetIndex("TEST1"));
  workbook.setSheetName(workbook.getSheetIndex(sheet), "TEST2");

  FileOutputStream os = new FileOutputStream("res.xls");
 } catch (Exception e) {

[res.xls : attachment]
 A sheet(TEST1) has 2 cells(A1,B1) that has comment.
 A cell(A1) on sheet(TEST2) has not comment.
 TEST2 cloned from TEST1.
Comment 1 Evgeniy Berlog 2012-08-18 14:44:22 UTC
This problem should be fixed in trunk.

Please try with a nightly build - see download links on http://poi.apache.org/
or build yourself from SVN trunk, see http://poi.apache.org/subversion.html
Comment 2 Arimitsu 2012-08-20 06:21:45 UTC
I get source files from SVN trunk,and Test on 20 august.
Exception at [workbook.write(os);]

java.lang.IllegalStateException: found multiple cell comments for cell $B$1
	at org.apache.poi.hssf.usermodel.HSSFPatriarch.preSerialize(HSSFPatriarch.java:110)
	at org.apache.poi.hssf.usermodel.HSSFSheet.preSerialize(HSSFSheet.java:144)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.getBytes(HSSFWorkbook.java:1248)
	at org.apache.poi.hssf.usermodel.HSSFWorkbook.write(HSSFWorkbook.java:1167)
Comment 3 Evgeniy Berlog 2012-08-20 07:06:28 UTC
According to the exception one of your sheets contains two or more comments for single cell. Please attach to this ticket source code and input file to reproduce this exception.

Regards, Evgeniy
Comment 4 Arimitsu 2012-08-27 02:33:40 UTC
Created attachment 29282 [details]
A file for test input
Comment 5 Arimitsu 2012-08-27 02:38:08 UTC
Test source code is the same as before. 
The Excel file(test.xls) used for the test attached at 2012-08-27 02:33. 

Comment 6 Evgeniy Berlog 2012-08-27 18:57:49 UTC
Hi Arimitsu

Source file you've attached contains 2 comments for cell B1. However Excel correctly reads this file. Can you please explain me, how did you create such file using Excel or POI tools, so I will understand whether this file is corrupted and you should only create new file or consider this situation more detailed.

Regards, Evgeniy
Comment 7 Arimitsu 2012-09-03 04:48:10 UTC

I should have checked again using other files. 
I'm sorry.
I have forgotten how the old test file was created.

I created test file newly and checked that a clone of the first comment was performed.