NetTalk Central

Author Topic: Serve file - download or open?  (Read 3776 times)

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Serve file - download or open?
« on: June 08, 2020, 12:22:26 AM »
I have a form with a start button and a progress control. The start button calls a source procedure that creates an xml file using the xCell class in xFiles. The file is being generated and the progress is being updated - and when the source proc is finished the progress changes to a download link. So far so good.

Now, if I (left) click the download link the raw xml file opens in the browser, but if I right click the download link and save the file, I can then (left) click the file and it opens in Excel (which is the desired behavior).

I've studied (and copied) the generated code in the ExportToExcel routine but I must be missing something. I would like the file to open in Excel when the download link is clicked. But how?

Peter

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Serve file - download or open?
« Reply #1 on: June 10, 2020, 08:41:06 PM »
Hi Peter,

The export code is a little different because it doesn't have a progress bar. So what it does is not going to be terribly useful to you.

For the record, the important bit that it does do is set;
  p_web.HeaderDetails.ContentDisposition = 'attachment; filename="Customer.xml"'
  p_web.ReplyContentType = 'application/vnd.ms-excel'
  p_web.ReplyContentFixed = true

that's what makes it open in excel, and not display in the browser.

But as I say, not terribly useful because your context is different.

So, for the next build (11.38) I've added two options. So you can "force" the name the file will be downloaded as. (this needs to be set to force a download.) And a reply content type that you can set.
I can't promise the xml file will open in Excel - that's up to your browser - but it's the same as the browse export.

cheers
Bruce