Ctrl+f搜关键词,搜不到找其他博客,下面肯定没有
写入excel
import openpyxl
wb = openpyxl.Workbook()
sheet = wb.active
cell = sheet['A1']
cell.value='你'
lst=['1','2']
sheet.append(lst)
wb.save('myexcel.xlsx')
结果
读取excel
import openpyxl
wb = openpyxl.load_workbook('myexcel.xlsx')
sheet = wb['Sheet']
cell = sheet['A1']
value = cell.value
print(value)
sheet.rows
wb = openpyxl.load_workbook('nihao.xlsx')
for sheet in wb:
data = sheet.rows
data = tuple(data)
for row in data:
for cell in row:
print(cell.value)
结果: