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', 'Hallo')
# Text with formatting.
worksheet.write('A2', 'Welt', 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()
Excel和XlsxWriter使用ASCII或UTF-8。要在Python2中编写这样的字符串:
像这样:
在python3中,您只需要将文件编码为UTF-8。在
参见Unicode examples in XlsxWriter docs。在
我看过你的问题做了一些调查,找到了一个例子。在
应该在工作;) 更多信息请访问:XlsxWriter
相关问题 更多 >
编程相关推荐