If a cell contains multiple hyperlinks, the approach mentioned in the following link doesn't work:
Extracting Hyperlinks From Excel (.xlsx) with Python
Is there any way to extract multiple hyperlinks in a cell preferably using openpyxl library?
Asked
Active
Viewed 152 times
-2

Shakkir Moulana
- 21
- 7
-
So do you mean you want the hyperlink from shape(s) placed over the text in the cell rather than from the cell itself? – moken Dec 12 '22 at 10:32
1 Answers
1
If it is done by shapes, I don't know of any other way to have multiple hyperlinks in the same cell, then Openpyxl cannot do. Have to use Xlwings.
import xlwings as xw
wb = xw.Book('foo.xlsx')
ws = wb.sheets('Sheet1')
for shape in ws.api.Shapes:
print(f'Hyperlink: {shape.Hyperlink.Address}')

moken
- 3,227
- 8
- 13
- 23
-
-
Thanks for your answer. But, I'm using CentOS, xlwings doesn't work for xlsx files on Linux. – Shakkir Moulana Dec 12 '22 at 11:29
-
I see your problem, but Openpyxl doesn't have much support for shapes. However you haven't confirmed if this is indeed what you are attempting to obtain in case the links are created in some other way. Shapes is the only way I know to do it, and looks like it from the image, but in case this is something different, need to be sure we are looking at the same thing. – moken Dec 12 '22 at 12:06