OO-Snippets: CellAttributes

Commons

Keywords
LanguageooRexx
ApplicationCalc
AuthorsMichael Hinz (initial)
Supported Versions2.0.x  
Supported OSWin32  
QuestionHow can i change cell attributes
Answer

Code-Snippet-Listing (snippet-source)

/* get the desktop  (an Xdesktop object) */
oDesktop = UNO.createDesktop()   
xComponentLoader = oDesktop~XDesktop~XComponentLoader      --get componentLoader interface
                                                      
/* open a blank calc file */
url = "private:factory/scalc"
xCalcComponent = xComponentLoader~loadComponentFromURL(url, "_blank", 0, .UNO~noProps)


/* get first sheet in spreadsheet */
xDocument = xCalcComponent~XSpreadSheetDocument
xSheet = xDocument~getSheets~XIndexAccess~getByIndex(0)~XSpreadSheet

/* get cell address */
xCell = xSheet~getCellByPosition(0, 0)
xCell2 = xSheet~getCellByPosition(0, 1)

/* set cell properties */
xCell~xPropertySet~setPropertyValue("CharWeight", box("float",bsf.getConstant("com.sun.star.awt.FontWeight", "BOLD")))

xCell2~xPropertySet~setPropertyValue("CellBackColor", box("int", "CCCCCC"x ~c2d))

/* insert  values into cells */
CALL UNO.setCell xSheet, 0, 0, "CharWeight"
CALL UNO.setCell xSheet, 0, 1, "CellBackColor"

::requires UNO.cls       -- get UNO support

Changelog

DateUserModification

and