from openpyxl import load_workbook
# 打开一个workbook
wb = load_workbook(filename=r"C:\Users\test.xlsx")
file_handle=open(r'C:\Users\1.txt',mode='w')
writetext=''
for itemname in wb.sheetnames:
ws = wb[itemname]
rows = ws.rows
columns = ws.columns
for row in rows:
line = ''.join([col.value for col in row])
print(line )
writetext+=line+'\n'
print(line)
file_handle.write(writetext)
file_handle.close()