NetTalk Central

NetTalk Web Server => Web Server - Ask For Help => Topic started by: astahl on December 03, 2014, 08:11:20 AM

Title: displaying an Excel or Word doc using a link
Post by: astahl on December 03, 2014, 08:11:20 AM
How does one show a document using a hotlink from a browse. For viewing only, no edits or saves from the server.


Ashley
Title: Re: displaying an Excel or Word doc using a link
Post by: Bruce on December 03, 2014, 08:35:04 AM
what format is the document in?

cheers
Bruce
Title: Re: displaying an Excel or Word doc using a link
Post by: astahl on December 03, 2014, 09:38:58 AM
Bruce,

The format for docs is either .doc, .docx, and .rtf. For Excel .xls, .xlsx, .csv, and .txt(tab delimited). The files are stored in the folder web\upload and all I want to be able to to do is when a user clicks on the link the browser is smart enough to use the appropiate program to display.

I would imagine a download page would have to be created and once downloaded it could/would do a ShellExecute.

Ashley
Title: Re: displaying an Excel or Word doc using a link
Post by: peterH on December 03, 2014, 01:23:23 PM
Hi Ashley,
You can do it by setting the appropriate content-type when serving the file. The browser will then know how to handle the file. It can render a simple text file directly. For other file types it will invoke the program registered by Windows for that file type. That's a parrallel to using ShellExecute in a desktop app. Thinking about it, the browser may actually even call ShellExecute, but I don't know that for sure.

The File Download examples, this forum and Google are your friends here, Lots of information around.

Peter
Title: Re: displaying an Excel or Word doc using a link
Post by: Bruce on December 03, 2014, 09:52:52 PM
Hi Ashley,

The content-type should take care of it for you - and that is set automatically, based on the file's extension.

So the browse can just contain a URL, and if the user clicks the link they'll get the file. Some browsers prompt you to "save or open" but that can depend on browser settings etc.

You can force that save/open option (by setting the content-disposition header as the FileDownload example does) but I'm not sure if you can force that option off.

Cheers
Bruce
Title: Re: displaying an Excel or Word doc using a link
Post by: astahl on December 08, 2014, 04:21:46 AM
Thanks, just what I needed to know.

Ashley