| View previous topic :: View next topic |
| Author |
Message |
satabau General User

Joined: 12 Mar 2012 Posts: 34
|
Posted: Thu May 31, 2012 12:03 pm Post subject: [Solved] Centered Text Alignment of a cell [java] |
|
|
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 |
|
 |
karolus OOo Advocate

Joined: 22 Jun 2011 Posts: 208
|
Posted: Thu May 31, 2012 2:09 pm Post subject: |
|
|
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 |
|
 |
satabau General User

Joined: 12 Mar 2012 Posts: 34
|
Posted: Thu May 31, 2012 3:56 pm Post subject: |
|
|
Thank you very much!!
I was using the wrong property!!
in java is almost equal
| Code: |
cellProp.setPropertyValue("HoriJustify", 2 );
|
|
|
| Back to top |
|
 |
|