OpenOffice.org Forum at OOoForum.orgThe OpenOffice.org Forum
 
 [Home]   [FAQ]   [Search]   [Memberlist]   [Usergroups]   [Register
 [Profile]   [Log in to check your private messages]   [Log in

[Solved] Centered Text Alignment of a cell [java]

 
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API
View previous topic :: View next topic  
Author Message
satabau
General User
General User


Joined: 12 Mar 2012
Posts: 34

PostPosted: Thu May 31, 2012 12:03 pm    Post subject: [Solved] Centered Text Alignment of a cell [java] Reply with quote

I need to align the text in a cell and to set it bold.
I solved the second parte this way:
Code:

    XCell cell = xSpreadsheet.getCellByPosition(0,0);
    XPropertySet cellProp = (XPropertySet)UnoRuntime.queryInterface(XPropertySet.class, cell);
     cellProp.setPropertyValue("CharWeight",new Float(FontWeight.BOLD));

but I can't align the text.
I read that I could do something like:
Code:

cellProp.setPropertyValue("ParaAdjust", com.sun.star.style.ParagraphAdjust.CENTER);

but I have always an IllegalArgumentException.
I also tried to cast with (Object) or new Integer(.. but nothing.
Can you help me please?


Last edited by satabau on Thu May 31, 2012 4:16 pm; edited 1 time in total
Back to top
View user's profile Send private message
karolus
OOo Advocate
OOo Advocate


Joined: 22 Jun 2011
Posts: 210

PostPosted: Thu May 31, 2012 2:09 pm    Post subject: Reply with quote

Hi
For me this works:
Code:
from com.sun.star.table.CellHoriJustify import CENTER
context = XSCRIPTCONTEXT
def centersel():
    doc = context.getDocument()
    crange = doc.getCurrentSelection()
    crange.setPropertyValue("HoriJustify", CENTER)
    # crange.setPropertyValue("HoriJustify", 2 ) #works too without import-line


But its Python, you have translate to Java !

Karo
Back to top
View user's profile Send private message
satabau
General User
General User


Joined: 12 Mar 2012
Posts: 34

PostPosted: Thu May 31, 2012 3:56 pm    Post subject: Reply with quote

Thank you very much!!
I was using the wrong property!!
in java is almost equal
Code:

 cellProp.setPropertyValue("HoriJustify", 2 );
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    OOoForum.org Forum Index -> OpenOffice.org Macros and API All times are GMT - 8 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group