简体   繁体   English

如何使用Python将特定的数组值保存到Excel中的单元格?

[英]How do I save a specific array value to a cell in Excel with Python?

I'm trying to save an array value into a cell in Excel using Python, but I can work out how. 我正在尝试使用Python将数组值保存到Excel中的单元格中,但是我可以找到方法。

I tried all of the followings but none worked: 我尝试了以下所有方法,但均无效果:

 ws['A2'] = data[0][1]
 ws['A2'] = 'data[0][1]'
 cellValue = data[0][1]
 ws['A2'] = cellValue

Obviously, I'm a beginner in Python! 显然,我是Python的初学者! Thanks in advance! 提前致谢!

Use the standard lib xlwt: 使用标准的lib xlwt:

wb = xlwt.Workbook() #create your workbook
ws = wb.add_sheet(sheet_name)
ws.write(n,m,my_data) # where n is the target row and m the column 

in the end just save: 最后保存:

wb.save('workbook.xls')

暂无
暂无

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

相关问题 如何通过Python3.7中的Pandas Data Frame验证Excel工作表中的特定单元格值 - How do I verify specific Cell Value in an Excel Sheet through Pandas Data Frame in Python3.7 如何使用 python 在 excel 中获取特定列/单元格的水平值 - How do I get the value of a specific column / cell going horizontal in an excel using python 如何在Python中将值插入数组中的特定单元格? - How to insert value to specific cell in array in Python? 如何删除excel单元格末尾由python生成的特定字符? - How do I remove specific characters generated by python at the end of an excel cell? 如何在 Python 中现有的 excel 文件中向特定单元格插入值? - How to insert a value to a specific cell in an existing excel file in Python? 如何替换包含 Python Panda 中某些单词的单元格中的值,就像在 Excel 中一样? - How do I replace the value in a cell that contains certain words in Python Panda like in Excel? 如何返回单个单元格值而不是整行。 Excel 到 Python Tkinter - How do I return an individual cell value instead of the entire row. Excel to Python Tkinter python 如何在 excel 单元格中粘贴非字母数字字符串 - python how do I paste non alphanumeric string in a excel cell 如何使用python在excel单元格中仅加粗字符串的一部分 - How Do I Bold only part of a string in an excel cell with python 如何在特定单元格值下插入一行 - how do I insert a row for under a specific cell value
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM