openpyxl 按行读取excel为列表
# -*- coding: utf-8 -*-
from openpyxl import load_workbook
from openpyxl import Workbook
from openpyxl.cell.cell import ILLEGAL_CHARACTERS_RE

def rdxls2list(xlsx_path):
	full_list = []
	wb = load_workbook(xlsx_path, read_only=True)
	ws = wb.active
	for item in list(ws.rows)[1:]:
		values = []
		for val in item:
			values.append(val.value)
		full_list.append(values)
	return full_list

def main():
	xlsx_lisrt = rdxls2list('test.xlsx')
	print(xlsx_lisrt)

if __name__ == '__main__':
	main()
上一篇
下一篇