Hyperlink to a file in excel using python‏

2,366 views
Skip to first unread message

Pman

unread,
Oct 13, 2010, 6:19:35 PM10/13/10
to python-excel
I want to create a hyperlink in my excel sheet using python such that
when you click on that link (which is a file name (html file)), the
file automatically opens. This file is present in the same folder in
which the python code file is present.

I am using xlwt module. Example code below:

link= 'abcd.html'
sheet.write(x, y, link, format_style)


This file is present on my hardrive..This file is present in the same
folder in which the python code file is present...

John Machin

unread,
Oct 13, 2010, 6:38:36 PM10/13/10
to python...@googlegroups.com
On 14/10/2010 9:19 AM, Pman wrote:
> I want to create a hyperlink in my excel sheet using python such that
> when you click on that link (which is a file name (html file)), the
> file automatically opens. This file is present in the same folder in
> which the python code file is present.
>
> I am using xlwt module. Example code below:
>
> link= 'abcd.html'
> sheet.write(x, y, link, format_style)

Have you searched for "hyperlink" in this group's archive?

Have you read the section on Hyperlinks in the tutorial available from
http://www.python-excel.org ?

pratik khemka

unread,
Oct 14, 2010, 1:44:58 PM10/14/10
to python...@googlegroups.com
I think I did not frame the question in a proper manner..
 
I want to open pratik.html which is there in the same folder as the python program. I do not want to specify the path like you can see below in the code (blue) c:\Documents and Settings\My Documents..The reason for this is that I want the code to be portable , ie others should also be able to run the program on their computers in whichever folder they want to. In this situation the code wont work on other computers due to the path name specified.
 
Currently I am using this code below :
sheet.write(4,3,"file:///c:\Documents and Settings\My Documents\pratik.html",hyperlink_style)
 
What I want to know is that if there is a way to remove the blue part (path to file)..I think it should be possible because the file is present in the same folder as the python program..

Thanks,
Pratik
 
 
> Date: Thu, 14 Oct 2010 09:38:36 +1100
> From: sjma...@lexicon.net
> To: python...@googlegroups.com
> Subject: Re: [pyxl] Hyperlink to a file in excel using pythonï؟½
> --
> You received this message because you are subscribed to the Google Groups "python-excel" group.
> To post to this group, send an email to python...@googlegroups.com.
> To unsubscribe from this group, send email to python-excel...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/python-excel?hl=en-GB.
>

Nijhawan, Aman

unread,
Oct 14, 2010, 2:53:27 PM10/14/10
to python...@googlegroups.com

Pratik are you familiar with relative paths vs Absolute paths?

 

Check this link if you aren’t.

http://www.communitymx.com/content/article.cfm?cid=230ad

 

Thanks

Aman

 

From: python...@googlegroups.com [mailto:python...@googlegroups.com] On Behalf Of pratik khemka
Sent: Thursday, October 14, 2010 1:45 PM
To: python...@googlegroups.com
Subject: RE: [pyxl] Hyperlink to a file in excel using python‏

 

I think I did not frame the question in a proper manner..
 
I want to open pratik.html which is there in the same folder as the python program. I do not want to specify the path like you can see below in the code (blue) c:\Documents and Settings\My Documents..The reason for this is that I want the code to be portable , ie others should also be able to run the program on their computers in whichever folder they want to. In this situation the code wont work on other computers due to the path name specified.
 
Currently I am using this code below :
sheet.write(4,3,"file:///c:\Documents and Settings\My Documents\pratik.html",hyperlink_style)
 
What I want to know is that if there is a way to remove the blue part (path to file)..I think it should be possible because the file is present in the same folder as the python program..

Thanks,
Pratik
 
 
> Date: Thu, 14 Oct 2010 09:38:36 +1100
> From: sjma...@lexicon.net
> To: python...@googlegroups.com

> Subject: Re: [pyxl] Hyperlink to a file in excel using python‏


>
> On 14/10/2010 9:19 AM, Pman wrote:
> > I want to create a hyperlink in my excel sheet using python such that
> > when you click on that link (which is a file name (html file)), the
> > file automatically opens. This file is present in the same folder in
> > which the python code file is present.
> >
> > I am using xlwt module. Example code below:
> >
> > link= 'abcd.html'
> > sheet.write(x, y, link, format_style)
>
> Have you searched for "hyperlink" in this group's archive?
>
> Have you read the section on Hyperlinks in the tutorial available from
> http://www.python-excel.org ?
>
> --
> You received this message because you are subscribed to the Google Groups "python-excel" group.
> To post to this group, send an email to python...@googlegroups.com.
> To unsubscribe from this group, send email to python-excel...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/python-excel?hl=en-GB.
>

Reply all
Reply to author
Forward
0 new messages