'工作表'对象没有属性' cell'
我需要打开一个XLSX文档并为其着色。但是我不明白为什么它会显示细胞错误。我的算法工作如下:
打开xlsx,writer = pd.excelwriter(path,eNgire ='xlsxwriter')
worksheet = writer.sheets['Sheet1']
col_style = Font(name = "Reem Kufi", size = 12, color = "DB3B22", italic =True)
for i in range(2,40):
worksheet.cell(row = i, column = 3).font = col_style
错误: - 'worksheet'对象没有属性'cell'
I need to open an xlsx document and color it. But I don't understand why it shows cell error it. My algorithm works like this:
Open xlsx, writer = pd.ExcelWriter(path, engine='xlsxwriter')
worksheet = writer.sheets['Sheet1']
col_style = Font(name = "Reem Kufi", size = 12, color = "DB3B22", italic =True)
for i in range(2,40):
worksheet.cell(row = i, column = 3).font = col_style
Error:- 'Worksheet' object has no attribute 'cell'
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您将需要使用OpenPyXl的
loadWorkbook
而不是excelWriter
来实现所需的目标。此处更新的代码。请注意,我只使用新代码和所需的库更改了初始的打开文件和工作表,并且没有更改您的代码的其余部分。you will need to use Openpyxl's
loadworkbook
instead ofExcelWriter
to achieve what you are looking for. Updated code here. Note that I have only changed the initial open file and sheet using the new code and required libraries and not changed rest of your code.