简体   繁体   English

如何使用 xlsxwriter 将数据写入 xlsx 文件?

[英]How data write in xlsx file using xlsxwriter?

I am writing in excel file using python xlsxwriter module.我正在使用 python xlsxwriter 模块写入 excel 文件。

import xlsxwriter

workbook = xlsxwriter.Workbook(r"E:\python_SQL\bedroom number\2.xlsx")
sheet = workbook.add_worksheet("raviraj")
sheet.write(0, 0, "RAVIRAJ")

code is executing but no sheet is getting added in excel nor data in a cell.代码正在执行,但没有在 excel 中添加工作表,也没有在单元格中添加数据。

I am using windows 10 os and python 3.6.我正在使用 windows 10 操作系统和 python 3.6。 What I am missing?我错过了什么?

You need to close the workbook as well.您还需要关闭工作簿。 At the end of your code, add在代码的末尾,添加

workbook.close()

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

相关问题 如何使用xlsxwriter for python将数据导出到xlsx - How to export data to xlsx using xlsxwriter for python 如何在python中使用xlsxwriter将数据写入/更新到现有XLSX工作簿的单元格中 - How to write/update data into cells of existing XLSX workbook using xlsxwriter in python 如何使用xlsxwriter将数据写入不同的工作表? - How to write data to different sheets using xlsxwriter? 使用xlsxwriter编写.xlsx文件时出现UnicodeDecodeError错误 - UnicodeDecodeError error writing .xlsx file using xlsxwriter 如何导出用xlsxwriter编写的xlsx文件 - How to export a xlsx file written with xlsxwriter 使用 xlsxwriter 将表格从 Word (.docx) 写入 Excel (.xlsx) - Write tables from Word (.docx) to Excel (.xlsx) using xlsxwriter 如何使用 xlsxwriter 在没有 dataframe 的情况下写入 excel 文件 - how to write into excel file without dataframe using xlsxwriter 如何忽略使用 python xlsxwriter 生成的 .xlsx 文件中显示的“公式不一致”警告? - How to Ignore "Inconsistent Formula" warning showing in generated .xlsx file using the python xlsxwriter? 如何使用 xlsxwriter 和 python 将图像添加到 xlsx 文件的标题中? - How can i add an image to a header of a xlsx file using xlsxwriter and python? xlsxwriter创建的损坏的xlsx文件 - Corrupt xlsx file created by xlsxwriter
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM