请留下您的邮箱,我们将在2小时内将文件发到您的邮箱
:文件夹下excel表格合并到一张excel。
:
:
for dir_path, subpaths, files in os.walk(path):
for file in files:
file_path = os.path.join(dir_path, file)
b=xlrd.open_workbook(file_path)
count=len(b.sheets())
for sheet in b.sheets():
nrows=sheet.nrows
ncols=sheet.ncols
for i in range(nrows):
for j in range(ncols):
if (sheet.cell(i,j).ctype==3):
date_value=xlrd.xldate_as_tuple(sheet.cell_value(i,j),b.datemode)
cell_value=str(date_value[0]) '/' str(date_value[1]) '/' str(date_value[2])
else:
cell_value=sheet.cell_value(i,j)
worksheet.write(a i,j,cell_value)
a=a nrows
f.write('已读取:' file_path ',' '工作表' sheet.name ',' '行数:' str(nrows) ',' '已累计汇总:' str(a) '\n')
print('已读取:' file_path ',' '工作表' sheet.name ',' '行数:' str(nrows) ',' '已累计汇总:' str(a))
f.close()
workbook.close()