zoukankan      html  css  js  c++  java
  • get , write Excel

    class readXls():

    def read(self, name, sheetname):
    try:
    print('start read excel !')
    self.path = os.path.abspath(os.path.join(os.path.dirname(__file__), name))
    table = xlrd.open_workbook(self.path).sheet_by_name(sheetname)
    xldata = []
    for i in tqdm(range(1, table.nrows)):
    xldata.append(table.row_values(i))
    return xldata
    except Exception as e:
    raise e


    def getsql(excelname, sheetname, filename):
    if os.path.exists(filename):
    os.system('type nul>{}'.format(filename))
    sql_path = os.path.abspath(os.path.join(os.path.dirname(__file__), filename))
    xls = readXls()
    data = xls.read(excelname, sheetname)
    print(' start write sql !')
    with open(sql_path, 'a', encoding='utf-8') as f:
    for i in tqdm(data):
    postcode, teamcode, countrycode, = i
    if isinstance(teamcode, str):
    ==========================================================================
    class Write_excel(object):
    def __init__(self, filename, sheetname='用例+报告'):

    self.filename = filename
    self.sheetname = sheetname

    def write(self, i, j, value):
    if not os.path.exists(self.filename):
    wb = Workbook()
    sh = wb.create_sheet(self.sheetname)
    else:
    wb = load_workbook(self.filename)
    sh = wb[self.sheetname]
    sh.cell(i, j).value = value
    wb.save(self.filename)
  • 相关阅读:
    A*寻路算法
    Flump使用GPU渲染Flash动画
    Flash AS3.0 垃圾回收机制
    flash builder无法启动的解决方法
    AS3.0 BitmapData类介绍
    x&(x1)表达式的意义
    Feathers: Stage3D加速的UI组件
    Knockout.js入门
    TcxStyleRepository使用示例
    TPageControl使用代码节选
  • 原文地址:https://www.cnblogs.com/yaohu/p/12597126.html
Copyright © 2011-2022 走看看