Method
RangeObject.Insert(Shift, CopyOrigin)
Shift:
xlShiftDown
xlShiftToRight
CopyOrigin:
xlFormatFromLeftOrAbove
xlFormatFromRightOrBelow
#xlwings
sht.range(‘C3‘).insert(shift=’down’,copy_origin=’format_from_left_or_above’)
sht.range(‘B3:C5′).insert()
#xlwings API
#sht.api.Range(‘C3‘).Insert(Shift=xw.constants.InsertShiftDirection.xlShiftDown, CopyOrigin=xw.constants.InsertFormatOrigin.xlFormatFromLeftOrAbove)
#sht.api.Range(‘B3:C5′).Insert()
Sample Code
#Inserting Cells or Ranges
import xlwings as xw #Import the xlwings package
app=xw.App()
bk=app.books.open('insert.xlsx')
sht=bk.sheets.active #Get the active worksheet
#xlwings
sht.range('C3').insert(shift='down',copy_origin='format_from_left_or_above')
#sht.range('B3:C5').insert()
#xlwings API
#sht.api.Range('A2').Insert(Shift=xw.constants.InsertShiftDirection.xlShiftDown, CopyOrigin=xw.constants.InsertFormatOrigin.xlFormatFromLeftOrAbove)
#sht.api.Range('B4:C5').Insert()
#bk.close()
#app.kill()



Leave a Reply