用于创建excel xlsx文件的python模块。
XlsxWriter的Python项目详细描述
xlsxwriter是一个用于在excel 2007+xlsx中写入文件的python模块 文件格式。
xlsxwriter可用于将文本、数字、公式和超链接写入 多个工作表,支持格式化等功能, 包括:
- 100%兼容的Excel XLSX文件。
- 完全格式化。
- 合并单元格。
- 定义的名称。
- 图表。
- 自动筛选。
- 数据验证和下拉列表。
- 条件格式。
- 工作表png/jpeg/bmp/wmf/emf图像。
- 丰富的多格式字符串。
- 单元格注释。
- 与熊猫融合。
- 文本框。
- 支持添加宏。
- 用于写入大文件的内存优化模式。
它支持python 2.7、3.4+、jython和pypy,并且只使用标准库。
下面是一个简单的示例:
importxlsxwriter# Create an new Excel file and add a worksheet.workbook=xlsxwriter.Workbook('demo.xlsx')worksheet=workbook.add_worksheet()# Widen the first column to make the text clearer.worksheet.set_column('A:A',20)# Add a bold format to use to highlight cells.bold=workbook.add_format({'bold':True})# Write some simple text.worksheet.write('A1','Hello')# Text with formatting.worksheet.write('A2','World',bold)# Write some numbers, with row/column notation.worksheet.write(2,0,123)worksheet.write(3,0,123.456)# Insert an image.worksheet.insert_image('B5','logo.png')workbook.close()
请参阅完整文档,网址为:https://xlsxwriter.readthedocs.io
发行说明:https://xlsxwriter.readthedocs.io/changes.html