在原有的excel中设置超链接
''' 在原有的excel中设置超链接 ''' def excel_link(): neo_j_ = Neo4j150() util = neo_j_._util data_frame_link = util.excel_link(neo_j_._excel_link) book = load_workbook(neo_j_._excel_link) writer = pd.ExcelWriter(neo_j_._excel_link, engine='openpyxl') writer.book = book data_frame_link.to_excel(writer, "first") writer.save()
def excel_link(self,path): excel_file = pd.ExcelFile(path) sheet_names = excel_file.sheet_names rows_xi = ['id', '疾病'] rows = [] for sheet_raw in range(len(sheet_names)): row = [] hyperlinks = '=HYPERLINK("%s", "%s")' % ('#' +sheet_names[sheet_raw] + '!A1', sheet_names[sheet_raw]) row.append(sheet_raw) row.append(hyperlinks) rows.append(row) data_frame = pd.DataFrame(rows, columns=rows_xi) return data_frame