0

I want to open a file using ms-excel. I read the method at URI Schemes Documentation. I am using the following code.

<a href='ms-excel:ofe|u|file:C:/Users/*********/Downloads/testätür.xlsx'>link</a>

This works fine if my filepath contains only english characters, however it gives error when using non English characters like ö,ä,ß. The link works fine without the 'ms-excel:ofe|u|' and downloads the file but it doesn't work with it. So I can only assume the problem is here.

file:C:/Users/***********/Downloads/testätür.xlsx

If I try to open the file link above, the following error occurs enter image description here

Can someone help me understand the issue here?

Ali Turab Abbasi
  • 1,103
  • 8
  • 22
  • 1
    Your link to the docs says literally that an [`ofe` command](https://learn.microsoft.com/en-us/office/client-developer/office-uri-schemes#edit-document) _requires_ a URI to the document based on the **http or https scheme**. So a URI based on the [file scheme](https://en.wikipedia.org/wiki/File_URI_scheme) can't work… – JosefZ Jul 19 '21 at 14:36
  • @JosefZ Yes I have read that but I only have a file path. Somehow it works fine without any special characters so I was guessing there is some issue of encoding – Ali Turab Abbasi Jul 19 '21 at 15:04
  • @AliTurabAbbasi Did you find the solution for this? I'm experiencing same issues. – knile Oct 12 '21 at 00:29
  • @AliTurabAbbasi Well JosefZ from comments is right, I kinda missed the http-schema part. I'll try something like this https://learn.microsoft.com/en-us/troubleshoot/windows-server/networking/create-virtual-directory-folder-remote-computer where I can use virtual directory under wwwroot folder and create links from there. – knile Oct 12 '21 at 00:55

1 Answers1

0

You need to encode the file path properly before using a hyperlink in the document. See What is the proper way to URL encode Unicode characters? for more information on that.

Eugene Astafiev
  • 47,483
  • 3
  • 24
  • 45
  • I have tried encoding my link as well but it doesn't work. I think the MS Excel needs a decoded file path whereas when we have to pass the file path as a URI, it has to be encoded. Could you suggest a workaround? – Ali Turab Abbasi Jul 20 '21 at 07:57