Links from Excel and session cookies

Jul 30, 21:45

Just a quick note on odd MS Excel handling of links. I did some excel exporting recently and added links to our site’s password protected pages to the resulting xls file. And while links were opening in default browser (Firefox), they were redirected to the login page, regardless of all the session and ‘remember me’ cookies that were in the Firefox.

After some intensive googling I found this JIRA issue , which contained the link to Microsoft KB article describing the very problem I’ve got.

As it turned out, Excel uses some IE-related DLL (Hlink.dll, if anyone cares) to open links from its worksheets, so it can only use IE cookies. And if your default browser is not IE, sorry, you’re out of luck. Basically, KB article proposed two ways to deal with that – you can add some registry keys to force Excel to use default browser for links instead of Hlink.dll, or you can do client-side redirect. That would force the client to the default browser as well.

Since we clearly couldn’t expect our customers to fiddle with registry keys, I decided to go the second route. Problem was solved by adding special param (xls_link=true) to the generated links, and one more before_filter in application_controller.rb, which looks like this

Sergey Pariev

en, rails



Комментирование этой статьи закрыто.