`

python读写xls

阅读更多

读取xls:

 

xls_data = xlrd.open_workbook('D:\\delete\\aaaaaa.xls')

sheetName = xls_data.sheet_names();

print sheetName

 

table = xls_data.sheets()[0]

 

rownum = table.nrows;

colnum = table.ncols;

 

print rownum

i=0

while i<rownum:

    rowValue = table.row_values(i);

    j = 0

    while j<colnum:

        print rowValue[j]

        j = j+1;

    print table.row_values(i)

    i = i+1

    

 

    

for i in range(0,rownum-1):

    for j in range(0,colnum-1):

        print table.cell(i,j).value

 

 写xls:

 

file = xlwt.Workbook(encoding='utf-8',style_compression=0)

 

table = file.add_sheet('bbbb',cell_overwrite_ok=True)

 

table.write(0,0,'bbbb_张博')

 

file.save('D:\\delete\\bbbb.xls');

 

 

 

 

 

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics