# Encoding: utf-8
# Date: 2019/5/30
# Name: 仲玲
from openpyxl import load_workbook
import os

class Excerl_Method():

	def __init__(self,logger,sheetname):
		self.logger = logger
		self.workname = os.path.dirname(os.path.abspath("."))+"\\data\\testdata.xlsx"
		# logger.error("获取文件路径出错")
		self.wb = load_workbook(self.workname)
		self.sheet = self.wb.get_sheet_by_name(sheetname)
		self.max_column = self.sheet.max_column

	def read_excel(self):
		data_list = []
		for row in self.sheet.rows:
			cell_list = []
			for cell in row:
				cell_list.append(cell.value)
			data_list.append(cell_list)
		return data_list[1:]

	def write_excel(self,row,text):
		self.sheet.cell(row,self.max_column,text)
		self.wb.save(self.workname)

if __name__ == '__main__':
	from commen.log_method import Log_Method
	logger = Log_Method().get_logger()
	excel = Excerl_Method(logger,"login")
	data= excel.read_excel()
	write = excel.write_excel(3,"pass")
	print(data)