module 'xlwings' has no attribute 'Book'

爷,独闯天下 提交于 2020-08-05 10:05:48

问题


I'm trying to use xlwings for the first time but I can't quite understand the documentation. From the section "Quickstart" I read

import xlwings as xw       

wb = xw.Book()  # this will create a new workbook    

When I try this "at home", I have no problem importing xlwings but with the second script I get this error:

AttributeError: module 'xlwings' has no attribute 'Book'

When I try to see the attributes of xw I can see AboveBelow,ActionTime etc. but not Book.

Can you help please?

Thank you very much.


回答1:


I had the error also and changed from Workbook to Book. It is a version issue.

wb = xw.Workbook()




回答2:


This fixed the issue for me:

import xlwings as xw
wb = xw.book()

I opened the excel file and seen book written as Book(first capital letter), so I changed it in the code as below:

import xlwings as xw
wb = xw.Book()


来源:https://stackoverflow.com/questions/41184203/module-xlwings-has-no-attribute-book

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!