[Solved] Calc - Insert Comment to Cell

The Application Programming Interface and the OASIS Open Document Format

[Solved] Calc - Insert Comment to Cell

Postby ikw_chen » Sun Jun 05, 2011 4:04 pm

Hi All,

I would like to insert comment into calc's cell, but on the xCell interface only have two method setValue and setFormula.

Code: Select all   Expand viewCollapse view
XSpreadsheet xSheet = (XSpreadsheet)UnoRuntime.queryInterface(XSpreadsheet.class, oSheet);

xCell = nameRange.getCellByPosition(0, 1);

xCell.setValue
xCell.setFormula


Thanks for advices!
Last edited by ikw_chen on Mon Jun 06, 2011 6:24 pm, edited 1 time in total.
Openoffice 3.3 on WinXP
ikw_chen
 
Posts: 17
Joined: Tue Apr 12, 2011 4:03 pm

Re: Calc - Insert Comment to Cell

Postby Zizi64 » Sun Jun 05, 2011 7:48 pm

Hi,

I found some examples:
http://www.oooforum.org/forum/viewtopic.phtml?t=32826
but do not work for me in my LibreOffice3.3.2....
Tibor Kovacs, Hungary; LO6.1.6, 6.2.8 /Win7-10 x64Prof.
PortableApps/winPenPack: LO3.3.0-6.4.5;AOO4.1.7
Please, edit the initial post in the topic: add the word [Solved] at the beginning of the subject line - if your problem has been solved.
User avatar
Zizi64
Volunteer
 
Posts: 9531
Joined: Wed May 26, 2010 7:55 am
Location: Budapest, Hungary

Re: Calc - Insert Comment to Cell

Postby FJCC » Sun Jun 05, 2011 9:41 pm

I found this approach in the Developer's Guide and it works for me. The Annotations are handled as a collection at the sheet level, not on a cell by cell basis.
Code: Select all   Expand viewCollapse view
Sheets = ThisComponent.Sheets
Sheet = Sheets.getByIndex(2)
Annotations = Sheet.getAnnotations()
Cell = Sheet.getCellrangeByName("E7")
CellAddr = Cell.CellAddress
Annotations.insertNew(CellAddr, "The new annotation text")
Cell.Annotation.isVisible = True
Windows 10 and Linux Mint, since 2017
If your question is answered, please go to your first post, select the Edit button, and add [Solved] to the beginning of the title.
FJCC
Moderator
 
Posts: 7736
Joined: Sat Nov 08, 2008 8:08 pm
Location: Colorado, USA

Re: Calc - Insert Comment to Cell

Postby ikw_chen » Mon Jun 06, 2011 6:23 pm

Hi FJCC,

Thanks so much for your quick reply, It works fine with below code:

Code: Select all   Expand viewCollapse view
XCellAddressable xCellAddr;
CellAddress aCellAdd;
                     
xCellAddr = (XCellAddressable)UnoRuntime.queryInterface(XCellAddressable.class, xCell);
aCellAdd = xCellAddr.getCellAddress();
                     
// insert an annotation
XSheetAnnotationsSupplier xAnnotationsSupp = (XSheetAnnotationsSupplier) UnoRuntime.queryInterface(XSheetAnnotationsSupplier.class, xSheet);
XSheetAnnotations xAnnotations = xAnnotationsSupp.getAnnotations();
xAnnotations.insertNew(aCellAdd, "This is comment");


Regards,
Openoffice 3.3 on WinXP
ikw_chen
 
Posts: 17
Joined: Tue Apr 12, 2011 4:03 pm


Return to UNO API and ODF

Who is online

Users browsing this forum: No registered users and 2 guests