#4 SetPropertyValue in XColumnRowRange does not work

ooRexx (4)
JM Buisson

Hello everybody,

I tried to assign width to eackh column of a spreadsheet, but all the property settings except one does not work. I do'nt know where is the problem UNO, BSF, java or LibreOffice.
Hereafter is the simplified code I used
/*--------------------------------------------------- start of extract ---------------------------------------------------------*/
xContext = UNO.connect()
xDesktop = UNO.createDesktop(xContext) /* get the OOo XDesktop interface to the service object */
xComponentLoader = xDesktop~XComponentLoader /* get XComponentLoader interface */
/* create new calc document */
url = "private:factory/scalc"
calcComponent = xComponentLoader~loadComponentFromURL(url, "_blank", 0, .UNO~noProps)
/* Rename the default spreadsheet */
xSheet = calcComponent~XSpreadSheetDocument~getSheets~XIndexAccess~getByIndex(0) ~XNamed
/*--------------------------- here some code not pertinent then --------------------------------------*/
wksDetail = calcDocument~getByName("Detail") ~XSpreadSheet
/* ..... define titles on rows 1 and 2 ..... not useful then*/
c = calcDocument~getByName("Detail") ~XColumnRowRange
c0 = c~getColumns()
c5 = c0~getbyindex(1) ~XPropertySet
c5~setPropertyValue("WIDTH", 1025) /* does not work the width is not reduced from 2258 the default to 1025 */
/* Here I reduce manually the with to 1025 then execute */
c5~setPropertyValue("Width", 2258) /* no change on teh shhet of course , the previous command did not work */
c5~setPropertyValue("IsVisible", 0) /* This command works, the column is hidden */
c5~setPropertyValue("IsVisible", 1) /* Does not work, the column is still hidden */
/*--------------------------------------------------------------end of extract -------------------------------------------*/

I have to redifine the width af all columns of the speeadsheet in order it can be printable on one sheet.

Thanks a lot for your help


  • JM Buisson

    JM Buisson - 2012-09-24

    I missed my configuration
    Windows XP SP3 and all updates
    ooRexx 4.1.1
    BSF4ooRexx downloaded on Sept 7th 2012

  • Rony G. Flatscher

    Hi there,

    this looks like an AOO/LO programming problem. Properties are usually case-sensitivie, hence "WIDTH" is not the same as "Width"! Also, PropertyValues are of a certain type, that you need to research first.

    In your case you could try to research Java examples to see the exact spelling and data type of the PropertyValue in question. Judging e.g. from http://user.services.openoffice.org/en/forum/viewtopic.php?f=45&t=1844 the name is "Width" and the type "Integer". You could therefore try to code something like:

    c5~setPropertyValue("Width", box("int",2258))

    However, by default UNO.CLS has special support for getting and setting PropertyValues, trying autocasing and autoboxing. Hence, if it cannot set the property value you should get an error popup informing you of the cause. From this you should be able to infer whether the PropertyValue exists at all or if there is a type problem.

    In your case you could also try to use the reflections support in UNO.CLS to get a text output of the structure of the UNO object in hand, e.g. inserting a statement like

    say ppd(uno.getProperties(c5)) -- get all properties of the service object as a string encoding, break it up to become legible

    Use the "refcardOOo.pdf" reference sheet in the Information folder to learn about the UNO specific routines and methods and also about the string encodings of UNO types.

    (Also, you can always use either the routine uno.getDefinition(UNO_object) or send the message uno.getDefinition to an UNO object to get its string encoded type information, which you can break up in a more legible form for debug output by supplying it to the ppd()-routine.)

    Also: please study any error messages or popups calmly, as UNO.CLS (and BSF.CLS) try to give you understandable and comprehensive information about error conditions!

    Please report back, if this was helpful for you one way or the other!


  • JM Buisson

    JM Buisson - 2012-09-25

    Hi Rony,

    Many thanks for your answer. It works now, my last test was Column~setPropertyValue("Width", box("Long",Twidth~word(i)))
    because I had found somewhere in the wiki ref that Width was a Long, but It should not be the right property.
    I have just a comment about the structure of the API. I seems to me that it is not easy to find what I need whithin
    interfaces to apply and method to use due to the sliced structure. But it will be easier with your links and advices.
    Thank again for your help


  • JM Buisson

    JM Buisson - 2012-09-25
    • status: open --> closed
  • Rony G. Flatscher

    Yes, you are right. Due to the very fine granularity of UNO types it is a problem to get a (conceptual and factual) overview of all the UNO types and their structures. That is the reason, why UNO.CLS contains (underestimated) reflection support for UNO types and UNO objects.

    In addition, if you go into the BSF4ooRexx submenu "Utilties" and there into "OOo" you will find another useful tool for documenting UNO types such, that one becomes able to gain an overview of all UNO types that constitute another UNO type. The resulting swriter or PDF document has hyperlinks to the genuinge AOO/OOo documentation. This way these generated documents not only give a nice overview, but also serve as great starters for researching the relevant original OOO documentation!

    If you also click on the XREF-links, then you will get to the OOo cross-references which are also interesting, as one can learn which other UNO types use/refer the one you have at your hands.

  • Rony G. Flatscher

    • milestone: --> Solved

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.

No, thanks