编写程序,打开一个电子表格,
将列A中的单元格写入一个文本文件
将列B中的单元格写入另一个文本文件,
以此类推
#! python3
# ExcelToText.py
'''
编写程序,打开一个电子表格,
将列A中的单元格写入一个文本文件
将列B中的单元格写入另一个文本文件,
以此类推
'''
# 引用区
import openpyxl
# 前期
excelfilename = "New1.xlsx"
wb = openpyxl.load_workbook(excelfilename)
sheet = wb["Sheet1"]
# 操作
for y in range(1,sheet.max_column+1):
with open(str(y) + ".txt", "wt") as tf:
for x in range(1, sheet.max_row + 1):
text = str(sheet.cell(row=x,column=y).value)
tf.write(text)