0

I am creating an Excel file with classic ASP and everything works fine except for hyperlinks.

I use this to create the excel file:

Response.ContentType = "application/vnd.ms-excel"
Response.AddHeader "Content-Disposition", "attachment;filename=artigos.xls"

And this to create the hyperlink:

<a href="http://www.google.pt" >teste</a>

When I open the file in excel it appears as a link, but like this:

file:///c:\users\silvia\desktop%0d%0ahttp:\www.google.pt%0d%0a

2
  • How do you generate the excel? Is it just an HTML output? Commented Aug 30, 2013 at 11:48
  • yes. It is a normal table. Commented Aug 30, 2013 at 12:15

2 Answers 2

0

Verify that the hyperlink base property of the workbook is empty. If it's Excel 2003, look under File -> Properties -> Summary. If it's Excel 2010, look under File -> Information -> Document Properties -> Advanced.

The hyperlink base property is known to mangle hyperlinks.

Edit:

Another thing to try is use the HYPERLINK function. Explicitly tell Excel, the text in the cell is a hyperlink and include the http:// :

=HYPERLINK("http://www.google.pt")
Sign up to request clarification or add additional context in comments.

5 Comments

And in 2013? Where do I change this option?
I have found where I change this option, but doens not solve my problema... When I do the edit link it appears like this....%0d%0a%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20%20http:\www.google.pt%0d%0a...If I remove the strange caracteres it works
Looks like the value has a carriage return and a lot of spaces now. Let me update the answer trying to use the Hyperlink function.
thank you very much. The Hyperlink function worked. But know I´m with a encoding problem, because of the url. Our português caracters desapear...Do you have any ideia why?
I found that if I put =HYPERLINK("google.pt") it works fine... If I put =HYPERLINK("google.com";title) where title is "EY promove conferência IRC: Perspectivas Futuras" it appears ok. If I put =HYPERLINK("google.com/";title) it appears like this: =HYPERLINK("gmail.google.com/fff";"EY promove conferência IRC: Perspectivas Futuras")
0

If you are willing to put a little more work into it, you could use the Open XML API from Microsoft. With it you can create native Excel xlsx files. And also use all possible Excel features that you want.

1 Comment

What .Net Version are you using? But basically I don't see a reason why not?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.