我在利用xlwings时,出现问题,发现利用cmd输入xlwings quickstart projectname,生成的表格,可用我新编辑的代码的指定宏按钮,但是在桌面新建的xlsm却无法使用,提示的错误是要求对象,请问这是什么问题?
import xlwings as xw
@xw.sub
def excel_cut():
gr = xw.Book.caller()
# 在A30处输入你想要截取的行数
n = int(gr.sheets('Sheet1').range('A30').value)
app = xw.App(visible=False, add_book=False)
wb = app.books.add()
sheet1 = wb.sheets["sheet1"]
sheet1.range('A1').value = gr.sheets['Sheet1'][:n, :1000].value
sheet1.range('A1').column_width = 13
A = sheet1.range('A1:A1000')
B = sheet1.range('B1:ZZ1')
A.api.Font.ColorIndex = 33
A.api.Font.Bold = True
B.api.Font.Bold = True
B.api.Font.ColorIndex = 3
wb.save('C:/Users/86155/Desktop/excel_cut.xlsm')
wb.close()
app.quit()