借用的工具库
- xlwt
- xlrd
- xlutils.copy
主要实现的方式介绍
- 通过xlrd来读取对应的excel
- 通过xlwt来进行写入excel
- 通过xlutils.copy来建立xlwt与xlrd的通道
代码块
import os
import xlwt,xlrd
from xlutils.copy import copy
def write_to_excel(sheet_name):
file_name = 'test_1.xls'
if not os.path.exists(file_name):
workbook = xlwt.Workbook(encoding='ascii')
worksheet = workbook.add_sheet(sheet_name