NetTalk Central

Author Topic: displaying an Excel or Word doc using a link  (Read 4350 times)

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
displaying an Excel or Word doc using a link
« 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

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: displaying an Excel or Word doc using a link
« Reply #1 on: December 03, 2014, 08:35:04 AM »
what format is the document in?

cheers
Bruce

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: displaying an Excel or Word doc using a link
« Reply #2 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

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: displaying an Excel or Word doc using a link
« Reply #3 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

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: displaying an Excel or Word doc using a link
« Reply #4 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

astahl

  • Sr. Member
  • ****
  • Posts: 308
    • View Profile
    • Email
Re: displaying an Excel or Word doc using a link
« Reply #5 on: December 08, 2014, 04:21:46 AM »
Thanks, just what I needed to know.

Ashley