python将数据输出到excel中

  • 2021-02-24
  • 程序简版
  • 公开
简介import xlsxwriter workbook = xlsxwriter.Workbook('hello.xlsx') # 建立文件 worksheet = workbook.add_worksheet() # 建立sheet, 可以work.add_worksheet('employee')来指定sheet名,但中文名会报UnicodeDecodeErro的错误 worksheet.write('A1', 'Hello world') # 向A1写入 worksheet.write
import xlsxwriter

workbook = xlsxwriter.Workbook('hello.xlsx') # 建立文件
worksheet = workbook.add_worksheet() # 建立sheet, 可以work.add_worksheet('employee')来指定sheet名,但中文名会报UnicodeDecodeErro的错误

worksheet.write('A1', 'Hello world') # 向A1写入
worksheet.write(1,2,'guoshun')#向第3行第2列写入guoshun

workbook.close()