Version 6.4.0.3, tag libreoffice-6.4.0.3
[LibreOffice.git] / scripting / examples / python / SetCellColor.py
blob743a6daa948ba6e806669c9afd463b0ce9db02cd
1 def SetCellColor(x, y, color):
2 """Sets the background of the cell at (x,y) (zero-based column and row
3 indices, for example (2,3) == C4) on the first sheet and
4 returns the contents of the cell as a string.
5 """
6 #get the doc from the scripting context which is made available to all scripts
7 desktop = XSCRIPTCONTEXT.getDesktop()
8 model = desktop.getCurrentComponent()
9 #check whether there's already an opened document
10 if not hasattr(model, "Sheets"):
11 return ""
12 sheet = model.Sheets.Sheet1
13 cell = sheet.getCellByPosition(x, y)
14 cell.CellBackColor = color
15 return cell.String