With xlwings, I am trying to move a worksheet within a workbook to the end. For example, a workbook contains a collection of the following sheets:
Sheet1, Sheet2, Sheet3
How can I move Sheet1 after Sheet3 in order to get the following order?
Sheet2, Sheet3, Sheet1
If I use ws1.api.Move(Before=ws3.api)
with the Before
parameter the line works as expected, but it doesn't with the After
parameter. See example code:
import xlwings as xw
wb = xw.Book("test.xlsx")
ws1 = wb.sheets['Sheet1']
ws3 = wb.sheets['Sheet3']
ws1.api.Move(After=ws3.api)