python excle 2 txt

#coding:utf-8
from xlrd import open_workbook
import os, sys
reload(sys)
sys.setdefaultencoding("utf-8")
wb = open_workbook('F:/******.xls')
f = open("d:/list.txt", "w")
for s in wb.sheets():
	print 'Sheet: ', s.name
	for row in range(s.nrows):
		values = []
		for col in range(s.ncols):
			temp = s.cell(row, col).value
			if temp != '':
				f.write(str(temp))
			values.append(temp)
		print values
	print 
f.close()

你可能感兴趣的:(python excle 2 txt)