XlsxWriter 以Excel2007+XLSX文件格式编写文件
XlsxWriter创建 Excel.xlsx 文件
XlsxWriter,Python第三方库,用于以Excel2007+XLSX文件格式编写文件。将文本、数字、公式和超链接写入多个工作表,它支持格式化等功能,包括:
- 100% compatible Excel XLSX files.
- Full formatting.
- Merged cells.
- Defined names.
- Charts.
- Autofilters.
- Data validation and drop down lists.
- Conditional formatting.
- Worksheet PNG/JPEG/GIF/BMP/WMF/EMF images.
- Rich multi-format strings.
- Cell comments.
- Integration with Pandas and Polars.
- Textboxes.
- Support for adding Macros.
- Memory optimization mode for writing large files.
XlsxWriter应用实例
import xlsxwriter
# 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()
Github开源协议和stars
BSD-2-Clause license
Github 3.4k stars
XlsxWriter安装命令
pip install XlsxWriter
XlsxWriter Python版本要求
(可能是最新版本)It supports Python 3.4+
免责声明:内容编辑自网络,仅供参考,不保证正确性,不作任何决策依据!!以上数据皆截止于博文的写稿日期。