简体   繁体   English

xlsxwriter.Workbook AttributeError: 'module' object 没有属性 'Workbook'

[英]xlsxwriter.Workbook AttributeError: 'module' object has no attribute 'Workbook'

Saw this article Detail AttributeError: 'module' object has no attribute 'workbook' for the same and the error there was a typo."W" is uppercase for Workbook.看到这篇文章Detail AttributeError: 'module' object has no attribute 'workbook' for same and the error was a typo."W" is uppercase for Workbook. Also the package used is xlwt.同样使用的 package 是 xlwt。

I use Python 2.7 in unix. Installed XlsxWriter and used as below(Same example as given in the official page http://xlsxwriter.readthedocs.io/getting_started.html ) xlsx version is 0.9.3我在 unix 中使用 Python 2.7。安装 XlsxWriter 并使用如下(与官方页面http://xlsxwriter.readthedocs.io/getting_started.html中给出的示例相同)xlsx 版本为 0.9.3

import xlsxwriter
workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()

worksheet.write('A1', 'Hello world')

workbook.close()

I use XlsxWriter version 0.9.2.我使用 XlsxWriter 版本 0.9.2。

Please help me figure out what else could be wrong here.请帮我弄清楚这里还有什么问题。 Now i am able to get the excel output using xlwt package.现在我可以使用 xlwt package 获得 excel output。

Make sure your file isn't named xlsxwriter.py .确保您的文件未命名为xlsxwriter.py

If it is, which was why I got the same error, all import xlsxwriter will do is import the current file, and not the xlsxwriter module installed in your python environment.如果是,这就是我遇到相同错误的原因,所有import xlsxwriter都会导入当前文件,而不是安装在您的 python 环境中的 xlsxwriter 模块。

Hope this helps!希望这有帮助!

In xlswriter.py we have a module named contenttypes.py .xlswriter.py我们有一个名为contenttypes.py的模块。 There only they are importing copy.py .只有他们正在导入copy.py

I have a file called copy.py in the same folder.我在同一个文件夹中有一个名为 copy.py 的文件。 So it was throwing the same error for me.所以它给我抛出了同样的错误。 I just changed the file name.我只是更改了文件名。

I had this problem.我有这个问题。

Python is probably not finding the workbook after creating it, or it has changed its name by the time workbook.close() is called. Python 在创建工作簿后可能没有找到它,或者在调用workbook.close()时它已经更改了它的名称。 Run the script from the same directory and see if that works out for you.从同一目录运行脚本,看看是否适合您。

Use this format: (row, column, content)使用这种格式:(行、列、内容)

import xlsxwriter
workbook = xlsxwriter.Workbook('hello.xlsx')
worksheet = workbook.add_worksheet()

worksheet.write(0, 0, 'Hello world') #(row, column, content) 

workbook.close()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 没有名为xlsxwriter.workbook的模块-Ironpython - No module named xlsxwriter.workbook -Ironpython xlsxwriter 错误:AttributeError:'Workbook' 对象没有属性 'add_format' - xlsxwriter error: AttributeError: 'Workbook' object has no attribute 'add_format' xlsxwriter,openpyxl:“工作簿”对象没有“写”属性 - xlsxwriter, openpyxl: 'Workbook' object has no attribute 'write' AttributeError:“工作簿”对象没有属性“写” - AttributeError: 'Workbook' object has no attribute 'write' Python,将.csv转换为.xlsx时使用文件更正,而没有xlsxwriter.workbook模块 - Python, file corruoption when converting .csv to .xlsx, without xlsxwriter.workbook module Openpyxl:AttributeError:“工作簿”对象没有属性“单元格” - Openpyxl: AttributeError: 'Workbook' object has no attribute 'cell' 使用来自 xlsxwriter 的 Workbook 对象时,Workbook 对象没有属性“add_sheet” - Workbook object has no attribute 'add_sheet' when using Workbook object from xlsxwriter AttributeError:“工作簿”object 没有属性“add_format” - AttributeError: 'Workbook' object has no attribute 'add_format' AttributeError: 'workbook' object 没有属性 'max_row' - AttributeError: 'workbook' object has no attribute 'max_row' AttributeError:“工作簿”object 没有属性“iter_cols” - AttributeError: 'Workbook' object has no attribute 'iter_cols'
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM