colspan = {} if table.merged_cells : for item in table.merged_cells: for row inrange(item[0], item[1]): for col inrange(item[2], item[3]): if (row, col) != (item[0], item[2]): colspan.update({(row, col): (item[0], item[2])})
for i inrange(1, nrows): row = [] for j inrange(ncols): if colspan.get((i, j)): row.append(table.cell_value(*colspan.get((i, j)))) else: row.append(table.cell_value(i, j))
分析目标表格,需要筛选的电源数据格式如下:
需要筛选的光端机起终点数据格式如下:
根据数据格式,编写脚本:
扫描目录下所有目标excel表格
1 2 3 4 5 6 7 8 9
filelist=[]
for root, dirs, files in os.walk(".", topdown=False): for name in files: str=os.path.join(root, name) ifstr.split('.')[-1]=='xlsx': filelist.append(str)
for root, dirs, files in os.walk(".", topdown=False): for name in files: str=os.path.join(root, name) ifstr.split('.')[-1]=='xls': filelist.append(str)
colspan = {} if table.merged_cells : for item in table.merged_cells: for row inrange(item[0], item[1]): for col inrange(item[2], item[3]): if (row, col) != (item[0], item[2]): colspan.update({(row, col): (item[0], item[2])})
for i inrange(1, nrows): row = [] for j inrange(ncols): if colspan.get((i, j)): row.append(table.cell_value(*colspan.get((i, j)))) else: row.append(table.cell_value(i, j))