Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Excel links not loading pages, but when the link is pasted in the browser it works.

I have placed hyperlinks in an excel spreadsheet though my ruby-on-rails application. The links are to some privileged pages that require, After the login I am supposed to taken to the requested page. However, what happens is that after login I lang on the home page of the website. Interestingly, when I right-click the link in the excel and paste the link in the web-browser url, it works as expected. So I don't think it's my app's fault, but rather something in excel that I am missing?

My scenario is pretty much the same as this scenario: http://www.geekstogo.com/forum/topic/289186-excel-2007-hyperlink-loads-web-login-screen-not-linked-urlplease-help-me/

like image 738
Saad Rehman Shah Avatar asked Feb 21 '12 11:02

Saad Rehman Shah


People also ask

Why are my excel hyperlinks not working?

Check to make sure that you didn't rename the second worksheet—the one that is the target of the hyperlinks. When you create hyperlinks, each of them references the name of the worksheet you specify as the target. If you later rename the worksheet, then the hyperlinks may not work as expected.

Why are my links not working when I click on them?

Most likely problems with opening hyperlinks are connected with either the security restrictions of your Internet browser that doesn't allow opening pop-up windows, or with your Flash player plug-in that prevents you from opening URLs in local Flash files.

Why are my excel links not updating?

Go to Data > Queries & Connections > Edit Links. In the Source list, click the linked object that you want to update. You can select individual workbooks with Ctrl+click, or all of them with Ctrl+A. Click Update Values.

How do you make excel recognize links?

Solution: Double-click the cell or press F2 to enter the edit mode, go to the end of the URL and press the Space key. Excel will convert a text string into a clickable hyperlink.


2 Answers

This issue normally happens in IE and i also faced the same problem.

Solution to this is very simple

  1. Create a redirect.html page in your public folder (public folder because you are using ROR)
  2. Copy this to your redirect.html

<html>
<body>
Please wait, loading your page... 
<script type="text/javascript">
function getQuerystring(key) {
key = key.replace(/[\[]/,"\\\[").replace(/    [\]]/,"\\\]");
var regex = new RegExp("[\\?&]"+key+"=([^&#]*)");
var query = regex.exec(window.location.href);
return query[1];
}
window.location = window.location.protocol + "//" + window.location.host + "/" + getQuerystring('page');
</script>
</body>
</html>

  1. The links you are constructing in excel should be modified

    For e.g Old link - http://test.com/post/comments/1 New link should be - http://test.com/redirect.html?page=post/comments/1

  2. You need to pass the part of URL (after base url) as a param

How this works.

When user clicks a link in excel it points to redirect.html and the javascript constructs the actual URL and redirects again to proper page, user will be navigated to actual page if already logged in else redirected to Login/Home page.

like image 55
Bharath Avatar answered Nov 09 '22 09:11

Bharath


Not sure it's really an answer but I had the same problem with my application.

The whole application, including the home page, is protected (I'm using Devise). So whenever a user wants to access http://myapp, it redirects him to http://myapp/users/sign_in.

I think Devise uses a 301 or a 302 to redirect to the login screens.

My finding is that links clicked in Office and opening in IE cannot accomodate this redirect (no problem when Chrome is the default browser). Does it match your setup?

Ultimately, I have found no other solution but to link directly to the sign-in page... Maybe there are other options but I'm still looking for them.

EDIT: found this article (from 2006) about a bug in Outlook which totally matches our situation. Again, not a solution, but at least an explanation.

like image 26
Pierre Avatar answered Nov 09 '22 07:11

Pierre