其他分享
首页 > 其他分享> > excel的处理

excel的处理

作者:互联网

# -*- coding: utf8 -*-
import xlrd
import xlsxwriter
data = xlrd.open_workbook( "00-KIDSWANT-basis-20141114_双周计画.xls".decode('utf8').encode('gbk') )
table = data.sheets()[0]
nrows = table.nrows
ncols = table.ncols
workbook = xlsxwriter.Workbook('demo.xlsx')
worksheet = workbook.add_worksheet()


for i in range(nrows):
    for k in range(ncols+1):
        if k < ncols:
            table.put_cell(i,k,1,table.cell(i,k).value,0)
            worksheet.write(i,k,table.cell(i,k).value)
        else:
            worksheet.write(i,k,"hi")
workbook.close()













标签:nrows,ncols,处理,worksheet,excel,cell,workbook,table
来源: https://blog.51cto.com/u_13887992/2733462