Creating a hyperlink for a excel sheet: xlsxwriter
Asked Answered
C

3

7

Is it possible to create a hyperlink for a specific sheet of an excel file?

I want to open a sheet on the click of a cell which is on another sheet of the same excel file. For example, if someone clicks on 'A1' cell which is in the sheet2 the sheet1 will be opened and both the sheets are in the abc.xlsx file.

Chassepot answered 16/5, 2018 at 11:11 Comment(0)
M
8

You can do this with the XlsxWriter Worksheet write_url() method using the internal: URI. See the XlsxWriter docs on write_url().

Moulden answered 16/5, 2018 at 11:29 Comment(2)
I am doing this : worksheet.write_url('A1', "internal: 'sheet name'") and getting error that invalid rang.Chassepot
Thanaks it worked ! Only thing we have to do is we need to give the path of a complete cell of the sheet instead of only to the sheet path.Chassepot
B
2

To put a "Friendly Name" in the hyperlink use the string argument of write_url() method. For example, I did the following after setting the variable sheet_name, which in this case is both the name of the sheet to link to and the friendly name:

write_url(row, col, f"internal:'{sheet_name}'!A1", string=sheet_name)
Bellaude answered 7/6, 2020 at 13:9 Comment(0)
G
1

I was unable to get this to work using the "write_url(A1, "internal:'sheet name'!A2")" form. Can someone provide some guidance on this?

I was able to successfully add hyperlinks to internal cells using the form:

write('A1', '=HYPERLINK(CELL("address", 'sheet name'!A2), "Friendly Name")

NOTE: the word 'address' is literal/not a generic reference, and, the quotes need to be specified as shown (i.e., single quotes for a multi-word sheet name, and double quotes for the word 'address' and the 'Friendly Name'...

Goatsbeard answered 29/10, 2019 at 17:14 Comment(1)
“Can someone provide some guidance on this?” Rather than ask a question in answer you should ask a new question with some sample code that demonstrates the problem.Moulden

© 2022 - 2024 — McMap. All rights reserved.