I am exporting some information to an excel workbook using the awesome xlwt module for Python. I know that I can have a certain cell contain a hyperlink that points to an external site like this:
from xlwt import Workbook, Formula
wb = Workbook()
sheet = wb.add_sheet('testing links')
link = 'HYPERLINK("http://stackoverflow.com/"; "SO")'
sheet.write(0, 0, Formula(link))
wb.save("testbk.xls")
However, what I actually want to do is something like "drilling through" the document. I want cell A1 from "sheet1" to point to cell F5 in "sheet3" for example.
Does someone know if what I am asking is possible; and if so, what syntax I must use to accomplish that?
As answered on the python-excel forum:
STW to find out how a user does it in Excel:
=HYPERLINK("#Sheet3!F5","some text")
You'd probably want something like this:
# to get to a different sheet in XL, use the sheet name, an !, and then the
# cell coordinates. In this case, you're going to sheet3, cell F3
link = 'sheet3!F3'
# This is still a formula, so you should link it as such.
sheet.write(0, 0, xlwt.Formula(link))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With