def __init__(self): self.book = [ "AnneClass.xls", ] self.sheet = ["Grade7-1st", "Grade7-2st", "Grade7-3st"] self.field_name = [ "Number", "Name", "Math", "English", "Chinese", "History", "Geography", "Civic", "Biology", "Total_score", "Ranking" ] self.name = [] self.number = [] self.math = [] self.english = [] self.chinese = [] self.history = [] self.geography = [] self.civic = [] self.biology = [] self.total_score = [] self.ranking = [] self.totaldatalist = [ self.number, self.name, self.math, self.english, self.chinese, self.history, self.geography, self.civic, self.biology, self.total_score, self.ranking ] if not os.path.isfile(self.book[0]): ExcelRw.create_tample_file(self.book[0], self.sheet) for sheetname in self.sheet: for i, field in enumerate(self.field_name): ExcelRw.write(self.book[0], sheetname, 0, i, field) self.init_table_for_exist_excel(self.book[0], self.sheet[0])
def test_create_tample_file(self): sfilename = 'xxx.xls' slist = ['1', '2', '3'] field_name = [ "Number", "Name", "Math", "English", "Chinese", "History", "Geography", "Civic", "Biology", "Total_score", "Ranking" ] ExcelRw.create_tample_file(sfilename, slist) for sheetname in slist: for i, field in enumerate(field_name): ExcelRw.write(sfilename, sheetname, 0, i, field)
"(4) List ranking and write to rank.txt \n") key = input("Your choice:") if InputCheck.check(str(key), 2): break if key == '1': while True: print(colored("===Key in personal data===", "blue")) p.input_personal_data() print("==========================") while True: esc_key = input("Save and Leave choose 0. [1-9] continue:") if InputCheck.check(esc_key, 3): break if esc_key == '0': ExcelRw.write_table(p.book[0], p.sheet[0], p.totaldatalist) break elif key == '2': while True: print( colored("===Which student that you want to check?===", "blue")) while True: name = input("Name:") if InputCheck.check(name, 1): break p.list_personal_data(name) print("==========================") while True: esc_key = input("exit choose 0. [1-9] continue:") if InputCheck.check(esc_key, 3): break
def test_read(self): cvalue = [ ExcelRw.read(self.filename, self.sheetname, r, c) for r in range(2) for c in range(3) ] print(cvalue)
def test_write_table(self): ExcelRw.write_table(self.filename, self.sheetname, TestExcelRw.p)
def test_write(self): ExcelRw.write(self.filename, self.sheetname, 4, 4, "See")
def test_createfile_ifneed(self): ExcelRw.createfile_ifneed(self.filename, self.sheetname)