Excel内置的超链接限制为65530.
Source 1,Source 2,Source 3.
您可以绕过此限制using the HYPERLINK
function of Excel%.
因此,举个例子:
(pd.DataFrame([['test', '=HYPERLINK("https://www.google.com/")']]*65600, columns = ['Name', 'Link'])
.to_excel(f'step2_1.xlsx', index=False))
编辑
这说明了如何将列中的当前字符串轻松转换为Excel超链接公式:
df = pd.DataFrame([['test', 'https://www.google.com/']]*10, columns = ['Name', 'Link'])
df['Link'] = df.Link.apply(lambda x: f'=HYPERLINK("{x}")')
输出:
Name Link
0 test =HYPERLINK("https://www.google.com/")
1 test =HYPERLINK("https://www.google.com/")
2 test =HYPERLINK("https://www.google.com/")
3 test =HYPERLINK("https://www.google.com/")
4 test =HYPERLINK("https://www.google.com/")
5 test =HYPERLINK("https://www.google.com/")
6 test =HYPERLINK("https://www.google.com/")
7 test =HYPERLINK("https://www.google.com/")
8 test =HYPERLINK("https://www.google.com/")
9 test =HYPERLINK("https://www.google.com/")