Python处理03版xls的excel 需要用到xlrd、xlwt来读写,而处理07版xlsx的excel需要用到openpyxl,首先读取txt内容,写入xlsx中,然后在读取xlsx中的内容。
# -*- coding: utf-8 -*-
"""
Created on Wed Aug 9 16:03:01 2017
@author: weilian
"""
import openpyxl
import codecs
from openpyxl.utils import get_column_letter
def txt_to_xlsx(filename,outfile):
fr = codecs.open(filename,'r')
wb = openpyxl.Workbook()
ws = wb.active
ws = wb.create_sheet()
ws.title = 'Sheet1'
row =