This is not a mendix thing I think. The only thing that could make a difference is the option "show file in browser". Try to change this setting. We have this option set to false in different forms we're we can upload and download files.
When I try to download a docx file, my browser offers me two options. Open the file and save the file. When I open the file, Microsoft Word opens my file correctly. So after handling the file in your browser, your computer should take the lead to open it. You meantioned that the file you want to open has no extension. I thinks that's your problem. Because it has no extension, your computer doesn't know that it's a word or excel file.
Edit after comment: Maybe you could associate a filedocument to your object and then retrieve the guid of the file and set this a link in a virtual attribute. Or maybe using deeplinks. These are things you can't do simply by adding those files in your datagrid. See this explanation
Ok, I will test things with deeplinks and the suggestion of Michel for my datagrid. But can I expect that this makes the browser recognize this as a Word/Excel document? (If so, then the writing below is unnecessary.)
I tested 2 things to know more of downloading docx/xlsx files in browsers:
- just a simple link <a href="test.docx">test</a>
in a separate html file works for (my) browsers: the download is recognized as Word-doc.
- I think the "simple link example" cannot be compared to the Mendix-situation (because of the explanation-link from Samet Kaya, so I created a download-script in PHP like this
<?php
$dir = ""; //zelfde map
$file = 'Test.docx';
if ((isset($file))&&(file_exists($dir.$file))) {
header("Content-type: application/force-download");
header('Content-Disposition: inline; filename="' . $dir.$file . '"');
header("Content-Transfer-Encoding: Binary");
header("Content-length: ".filesize($dir.$file));
header('Content-Type: application/octet-stream');
/*Note that if I comment out the line below, the behaviour is like mendix: the download is not recognized as a Worddoc but as a zip-file or unknown extension*/
header('Content-Disposition: attachment; filename="' . $file . '"');
readfile("$dir$file");
}
?>
When I execute this script, I also get a file-download where the name is Test.docx is the filename and it is recognized as a Worddoc
Question: Is the Mendix-file-download so different that I cannot get this behaviour in mendix-apps? Or can I configure my webserver in a way that it still is recognized (I read something of missing MIME-types)?
In answer to Michel's comment (compare headers) I below post the part that (I think) is relevant:
Headers of the Mendix-download
HTTP/1.1 200 OK
Content-Type: application/octet-stream
Transfer-Encoding: chunked
Server: Jetty(7.0.1.v20091125)
Headers of the php-script
HTTP/1.1 200 OK
Server: Microsoft-IIS/5.1
Date: Wed, 23 Feb 2011 09:55:12 GMT
X-Powered-By: ASP.NET, PHP/5.3.4
Connection: close
Content-Type: application/octet-stream
Content-Disposition: inline; filename="Test.docx"
Content-Transfer-Encoding: Binary
Content-Length: 9969
I think the line marked in bold is important. Can this header be added (without needing a new version of the Mendix-Modeler)?