开发者

Delphi OpenOffice automation scalc center cell text

Hello could someone please help me with the following: I want to center the text in a scalc open office spreadsheet cell via Delphi and the OOoTools toolkit.

The following code does not work:

sRange := '$A$3:$A$3';开发者_运维技巧
ooParams := CreateUnoStruct('com.sun.star.beans.PropertyValue', 1);
ooParams[0].Name  := 'ToPoint';
ooParams[0].Value := sRange;
execDispatch('.uno:GoToCell', ooParams);

ooParams := CreateUnoStruct('com.sun.star.beans.PropertyValue', 1);
ooParams[0].Name  := 'HorizontalJustification';
ooParams[0].Value := 'com.sun.star.table.CellHoriJustify.CENTER';
execDispatch('.uno:HorizontalJustification', ooParams);

Has someone any idea why not? Thanks Ad


It seems that HorizontalJustification needs an enumvalue, but you're giving a string. You have to lookup the value of com.sun.star.table.CellHoriJustify.CENTER and fill your ooParams[0].Value with it.

Here is a way to lookup an enumvalue: http://www.oooforum.org/forum/viewtopic.phtml?t=16383

In your case com.sun.star.table.CellHoriJustify.CENTER equals 2, so you need:

ooParams[0].Name  := 'HorizontalJustification';
ooParams[0].Value := 2;
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜