Bug 41198 - HSSF: Support for excel cell comments
Summary: HSSF: Support for excel cell comments
Status: RESOLVED FIXED
Alias: None
Product: POI
Classification: Unclassified
Component: HSSF (show other bugs)
Version: unspecified
Hardware: Other other
: P2 normal (vote)
Target Milestone: ---
Assignee: POI Developers List
URL:
Keywords:
: 10215 (view as bug list)
Depends on:
Blocks:
 
Reported: 2006-12-18 00:19 UTC by Yegor Kozlov
Modified: 2007-03-12 09:16 UTC (History)
2 users (show)



Attachments
the patch (53.80 KB, patch)
2006-12-18 00:19 UTC, Yegor Kozlov
Details | Diff
zip archive with the modified and added files (61.12 KB, application/x-zip-compressed)
2006-12-18 00:20 UTC, Yegor Kozlov
Details
changed the license header as recently discussed (54.47 KB, patch)
2006-12-29 06:03 UTC, Yegor Kozlov
Details | Diff
zip archive with the modified and added files (62.56 KB, application/x-zip-compressed)
2006-12-29 06:06 UTC, Yegor Kozlov
Details
Attempt to remove a comment (2.29 KB, patch)
2007-02-08 08:15 UTC, Brian Kalbfus
Details | Diff
simple xls file with nothing but a comment (13.50 KB, application/octet-stream)
2007-02-19 16:26 UTC, Trejkaz (pen name)
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Yegor Kozlov 2006-12-18 00:19:00 UTC
This functionality was requested many times and finally it is here!

Docs, examples and unit tests are included. 

Regards, Yegor
Comment 1 Yegor Kozlov 2006-12-18 00:19:32 UTC
Created attachment 19277 [details]
the patch
Comment 2 Yegor Kozlov 2006-12-18 00:20:25 UTC
Created attachment 19278 [details]
zip archive with the modified and added files
Comment 3 Yegor Kozlov 2006-12-29 06:03:54 UTC
Created attachment 19324 [details]
changed the license header as recently discussed
Comment 4 Yegor Kozlov 2006-12-29 06:06:06 UTC
Created attachment 19325 [details]
zip archive with the modified and added files

changed the license header as recently discussed
Comment 5 Yegor Kozlov 2007-01-08 00:08:21 UTC
This long-awaited feature is implemented.
We had the request to implement excel comments since June 2002 (Bug 10215) and
finally it's done. 

Yegor
Comment 6 Yegor Kozlov 2007-01-08 00:10:44 UTC
*** Bug 10215 has been marked as a duplicate of this bug. ***
Comment 7 Brian Kalbfus 2007-01-29 06:24:48 UTC
Thanks for adding this function!  The getter works for me, but changes I make to
the comment are not reflected in the saved spreadsheet.  Looking at the code, it
appears to me that the setting of the properties on the comment private variable
is not enough to alter the drawing object and associate text object that make up
the actual comment stored in the spreadsheet.

Can you please add working setters on the HSSFComment class and a way to remove
comments?

Thanks!
Brian
Comment 8 Yegor Kozlov 2007-01-29 07:21:18 UTC
It's not a bug of the implementation, rather a restriction of the current HSSF
architecture.

The problem is that we can't modify properties of existing drawing objects. 
It means you can set properties of new shapes ( and comments) but can't modify
props of existing ones.

Thanks for pointing that out. I will see what I can do. 

Regards,
Yegor

Comment 9 Brian Kalbfus 2007-02-08 08:15:44 UTC
Created attachment 19547 [details]
Attempt to remove a comment

Yegor,

I added a removeComment method by mirroring your getComment method and removing
the note record.  I had code to also remove drawing objects and note records
from the sheet's records collection, but the spreadsheet became unreadable
after that -- I commented out that code.  Attached is the patch to
HSSFCell.java.	This at least makes the comments not appear in the spreadsheet,
though there may be some junk records hanging around that are not displayed by
Excel.	

In my situation I decided to not use comments for my purposes when the standard
read-write test failed to produce a readable workbook when run on a workbook
with over 44 commented cells.

Thanks,
Brian
Comment 10 Yegor Kozlov 2007-02-09 05:55:01 UTC
Brian,

Thanks. I will look at it.

Meanwhile, your request to make excel comments modifiable is implemented. 
Checkout the latest code. 

Modifiable attributes:
  - comment text
  - comment author
  - comment visibility
  - comment row and columns, i.e. it's possible to re-assign a comment to a
different cell.

NOT modifiable attributes:
 - all escher ones: background color, borders, etc.
 - anchor
These ones are much more difficult to implement and I'm putting it aside for
future. But if you have energy to implement it  - welcome. :)

Yegor
Comment 11 Trejkaz (pen name) 2007-02-19 16:26:08 UTC
Created attachment 19613 [details]
simple xls file with nothing but a comment

While this bug is reopened, could someone tell me why the XLS file I'm
attaching just now doesn't show up as having a comment when accessed through
the new API?
Comment 12 Yegor Kozlov 2007-03-12 08:59:28 UTC
Trejkaz,

Well, your example is a singular case. 
In XLS it's possible to have comments for non-existing cells. 
In your file the comment points to cell (0,0) which does not exist. HSSF returns
null for that cell and there was no way to get the comment.

I improved the API. Now it's possible to retrieve cell comments in two ways:
 - HSSFCell.getCellComment()  
 - HSSFSheet.getCellComment(int row, int column) - new method that returns cell
comment for a particular cell.

These methods share the same low-level code. use whatever is appropriate.

Regards,
Yegor  
Comment 13 Yegor Kozlov 2007-03-12 09:16:11 UTC
Brian,

I tried your patch to remove cell comments. Unfortunately it does not work.
Comments are not seen but the resulting XLS is corrupted. 

I did more experiments with no luck. It's not enough to just remove comment's
records. To remove comments (and any other shapes) we need to modify drawing
records/managers and this is the problem. The current architecture is not meant
to do that. It can only create drawings, not to modify them. 

There is no way to remove comments. Sorry.

Regards,
Yegor