Macros/Calc/py018

    From The Document Foundation Wiki
    < Macros‎ | Calc

    Description

    Insert a formula into a certain cell

    Python code

    def main(args=None):
        # ~ NAME_SHEET = 'Sheet1'
        document = XSCRIPTCONTEXT.getDocument()
        sheet = document.CurrentController.ActiveSheet
    
        # ~ If you want any other sheet
        # ~ sheet = document.Sheets[NAME_SHEET]
    
        cell = sheet['B11']
        cell.Formula = '=SUM(B2:B10)'
    
        sheet['B11:D11'].fillAuto(1, 1)
    
        return