# -*- coding: utf-8 -*-
# @__author__:choppa
# @DATA 2021/8/23
import xlrd
from tools import path_handle
def readExcel(exceldir, sheet_name):
"""
根据表格的表单名,以list格式返回表单的数据
:param exceldir: 表格路径
:param sheet_name: 表单名
:return:
"""
# 打开工作薄,加formatting_info= True 表示保留文件格式,但必须为xls,表格有内容时,切记一定加上
workdBook = xlrd.open_workbook(exceldir, formatting_info=True)
# 获取工作薄中的所有表单
# workdBook.sheet_names()
#以表单名查找表单
workSheet = workdBook.sheet_by_name(sheet_name)
relist = []
#循环从第二列开始循环,循环所有列
for one in range(1, workSheet.nrows):
#判读是否有空值列
if workSheet.row_values(one)[0] != '':
#将非空列添加进list
relist.append(workSheet.row_values(one))
#返回list
return relist
if __name__ == '__main__':
res = readExcel(path_handle.xls_dir, '登录模块')
print(res)