Search code examples
xlwings

Rename active excel workbook and sheet in python


Is it possible in python to rename an active workbook and sheet? I currently am using the xlwings "view" command to open my data frame up in excel which is nice but would like to have the active workbook/sheet named without saving it to a specified directory.

import xlwings as xw
xw.view(df)

When I try overriding the fullname of the active workbook I get an attribution error

xw.books.active.fullname = "Report"

AttributeError: can't set attribute


Solution

  • To rename the active Sheet in active Workbook you can try:

    xw.books.active.sheets.active.name = "test"