How To Enter R1C1 Style Formulas using FormulaR1C1 Property Using xlwings?

Method

sht.Range(‘C8′).FormulaR1C1=’=SQRT(R1C1)’

Sample Code

# Use `FormulaR1C1` property for R1C1-style formulas

import xlwings as xw    #Import the xlwings package
import os    #Import the os package

root = os.getcwd()    #Get the current path
#Create an Excel application window, visible, 
#without opening a workbook  
app=xw.App(visible=True, add_book=False)
#Open a data file, writable
bk=app.books.open(fullname=root+r'\Formula.xlsx',read_only=False)
sht=bk.api.Sheets(1)    #Get the worksheet

#Use `FormulaR1C1` property for R1C1-style formulas
sht.Range('C8').FormulaR1C1='=SQRT(R1C1)'

bk.save('test.xlsx')
#bk.close()
#app.kill()
Enter R1C1 Style Formulas using FormulaR1C1 Property Using xlwings
February 11, 2026 (0)


Leave a Reply

Your email address will not be published. Required fields are marked *