Method
Use the `AddTextbox` method of the `Shapes` object to create a text box. The calling format and parameters are similar to the `AddLabel` method.
shp=sht.api.Shapes.AddTextbox(1,10,10,100,50)
shp.TextFrame2.TextRange.Characters.Text=’Test Box’
Sample Code
#Create formulas using defined names
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()
bk=app.books.active
sht=bk.api.Sheets(1) #Get the worksheet
#Create formulas using defined names
sht.Range('C3').Value=10
sht.Names.Add(Name='NMT',RefersTo=sht.Range('C3').Value)
sht.Range('A1').Formula='=NMT+3'
#bk.save()
#bk.close()
#app.kill()

Leave a Reply