4 xlsxwriter

4.1 项目简介

XlsxWriter是用于创建Excel XLSX文件的Python模块。

4.2 项目地址

https://github.com/jmcnamara/XlsxWriter

4.3 文档地址

https://xlsxwriter.readthedocs.io/

4.4 最佳实践

pip3 install 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()


© pengpeng 本站总访问量修改时间: 2020-07-26

results matching ""

    No results matching ""