本文介绍了如何使用python中的xlsxwriter将数据写入/更新到现有XLSX工作簿的单元格中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
import xlsxwriter
def write_column(csvlist):
workbook = xlsxwriter.Workbook(filename.xlsx,{'strings_to_numbers':True})
工作表= workbook.add_worksheet()
row = 0
col = 0
for c in csvlist
workheet.write(col,row,i)
col + = 1
workbook.close()
但找不到在现有工作簿中写入的方式。
请帮助我使用xlswriter或任何替代方式在现有工作簿中编写/更新单元格。
解决方案
从 xlsxwriter
模块:
如果要修改现有的 xlsx
工作簿,请考虑使用模块。
另请参见:
I am able to write into new xlsx workbook using
import xlsxwriter
def write_column(csvlist):
workbook = xlsxwriter.Workbook("filename.xlsx",{'strings_to_numbers': True})
worksheet = workbook.add_worksheet()
row = 0
col = 0
for i in csvlist:
worksheet.write(col,row, i)
col += 1
workbook.close()
but couldn't find the way to write in an existing workbook.Please help me to write/update cells in existing workbook using xlswriter or any alternative.
解决方案
Quote from xlsxwriter
module documentation:
If you want to modify existing xlsx
workbook, consider using openpyxl module.
See also:
- Modify an existing Excel file using Openpyxl in Python
- Use openpyxl to edit a Excel2007 file (.xlsx) without changing its own styles?
这篇关于如何使用python中的xlsxwriter将数据写入/更新到现有XLSX工作簿的单元格中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!