NetTalk Central

Author Topic: Progress Bar - Opening Generated File Link  (Read 6930 times)

springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Progress Bar - Opening Generated File Link
« on: November 03, 2012, 04:01:06 AM »
NT 6.48
I have an app that is generating a file using the progress bar feature - that is working so slick.  I continue to be amazed at Bruce!!!

The file that I generate is a Text-Tab Delimited file with the file extension of .IIF.  This is a format that Quickbooks can use.  On my browser system, I have the .IIF file type set to be opened with Microsoft Excel, which, if you double click on the file, Excel opens the file right up and with the right formatting.

But, when I click the link to download the generated file, I do not get the option screen to either open the file with excel or to save the file.  Instead, I get a screen with the data displayed as a text file.

If I run the excel example or the progress bar example for file generation, I get those options - to open or save.

Is there something that I need to do to get the open/save option when I click the link on this text-tab delimited .IIF file?
Thanks,
Mike Springer

peterH

  • Sr. Member
  • ****
  • Posts: 413
    • View Profile
Re: Progress Bar - Opening Generated File Link
« Reply #1 on: November 04, 2012, 02:32:55 AM »
I think you need to set the content type. I'm sorry but I'm not at my pc right now so I can't be more specific.

Peter

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Progress Bar - Opening Generated File Link
« Reply #2 on: November 04, 2012, 09:48:58 PM »
Hi Mike,

you have two problems, and hence the solution is in two parts.

The first is, as Peter said, the content type. This is usually set automatically because of the file extension, but in your case the extension is IFF which may or may not be recognized as belonging to Excel.

You can "specify" that the downloaded file should be opened by excel though. The easiest approach is

p_web.ReplyContentType = p_web._GetContentType('.xls')


Since xls is "bound" to Excel, you are implicitly adding code into the reply to tell the remote browser "this is an excel file". In a NetWebPage you can do this after the call to

do header

If you are generating the file elsewhere let me know the context.

the second problem is forcing the browser to ask "save or download". this is done by setting the content disposition. As in something like;

p_web.HeaderDetails.ContentDisposition = 'attachment; filename="'&p_web.GetValue('name')&'"'

Again context is all important - but example 40 (FileDownload) serves as a good example.

Cheers
Bruce

springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Re: Progress Bar - Opening Generated File Link
« Reply #3 on: November 05, 2012, 05:20:56 AM »
Bruce,
I am generating the IIF file in this manner:

In a NetWebForm called QuickBookExport, I have a progress field (QBexportProgress) and a StartExport button.  The StartExport button calls a clarion source procedure called BuildQBFile. 

In the Clarion Source procedure, once I've created the file and saved it in a folder under the web folder, I pass the name and location of the file back to the QuickBookExport (netwebform) procedure with this:

 p_web.SetProgress(LOC:ProgressName,'\QBFolder\TestFile.IIF')

So, that is the context that I am working with - not a NetWebPage format.

Where would I put the Content Type setup?

Thanks,
Mike



springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Re: Progress Bar - Opening Generated File Link
« Reply #4 on: November 06, 2012, 02:16:09 AM »
Bruce,
Any advice on the right place to embed for this context?
Mike

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Progress Bar - Opening Generated File Link
« Reply #5 on: November 06, 2012, 07:16:02 PM »
not yet Mike (and I'm out all day today, so it'll probably only be tomorrow.)

I'm thinking the first thing to try is embed in the _GetContentType method in the web handler. I'd try something like this;
(after the parent call).

If instring('.iff',lower(p_filename),1,1)
   return ('application/vnd.ms-excel')
end


that may be sufficient.

cheers
Bruce


springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Re: Progress Bar - Opening Generated File Link
« Reply #6 on: November 07, 2012, 05:24:04 AM »
Bruce,
I know you are very busy this November and I appreciate your time.

I tried your suggestion in the web handler and it did not work.  That routine never sees the iif file, so the suggested code never runs for that file.  By the way, it doesn't matter if the code is before or after the parent call - the routine is never seeing the iif file name.

Also, as an aside, the computer that I am testing this on (using localhost) is set up so an iif file is handled by excel (in otherwords, if you double click on an iif file type, excel automatically opens it).  So, apparently the computer itself does know that this type of file is to be handled by excel.

I also notice that rather than clicking on the file link, that if you right click it and select "save link as" then you can save the iif file.  That can work as a procedural work around until you have a chance to advise on a solution. 

Remember that the progress bar and build file button are on a memory form and not a netwebpage.

Thanks for your great work!
Mike Springer



bshields

  • Sr. Member
  • ****
  • Posts: 392
    • View Profile
    • Inhabit
    • Email
Re: Progress Bar - Opening Generated File Link
« Reply #7 on: November 07, 2012, 02:18:39 PM »
Hi Mike,

You might also like to try naming the page that downloads the file with the .IFF suffix.

http://myserver.com/ExportQuickenData.IIF?etc&etc&etc

Some browsers also look at this.

Regards
Bill

kevin plummer

  • Hero Member
  • *****
  • Posts: 1195
    • View Profile
    • Production Accounting and Software Payroll
Re: Progress Bar - Opening Generated File Link
« Reply #8 on: November 07, 2012, 02:23:05 PM »
I would drop a debug point in before the code:

p_web._trace('p_filename=' & p_filename)
If instring('.iff',lower(p_filename),1,1)
   return ('application/vnd.ms-excel')
end

This may provide some clues.

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11244
    • View Profile
Re: Progress Bar - Opening Generated File Link
« Reply #9 on: November 07, 2012, 10:36:04 PM »
yeah, I'm with Kevin here - if it's not seeing the .IFF extension in the file, then what _is_ it seeing? ie what is p_filename set to when you click on the generated link?

cheers
Bruce

springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Re: Progress Bar - Opening Generated File Link
« Reply #10 on: November 08, 2012, 05:00:11 AM »
Guys,
Here is what I see...
As I work through the screens leading up to the file creation screen, I see the expected screen procedure file names at the _GetContentType method.

But, on the NetWebForm where I have the progress bar and button to create the file, and once the "Click Here to Download File" link appears, when I click on it, there is no call to the _GetContentType method.

If I hover the mouse over the download link (using Firefox) I see 127.0.0.1/QBFolder/Test.IIF displayed in the lower left of the browser screen (which is the expected path).  But, if I click on the link, no call at the _GetContentType, and a new tab in the browser opens and the text of the Test.IIF file is displayed on the browser screen.

Now, get this, if I right click on the link and select Save Link As, the _GetContentType method is called and the Test.IIF file name is detected in _GetContentType.  AFTER that, if I then click on the download link, the Test.IIF file name is detected in _GetContentType as you expected, and the proper messages about opening in excel or saving the file appear. 

So, for some reason, when I click on the link after it is generated, _GetContentType is not being accessed.  But it is if I right click on the link and select Save Link As, and after that, clicking on the link does access _GetContentType and the vnd.ms-excel code works perfectly.

Does that make sense?
Thanks for your help on this.
Mike

springguy

  • Full Member
  • ***
  • Posts: 195
    • View Profile
    • Email
Re: Progress Bar - Opening Generated File Link
« Reply #11 on: November 12, 2012, 03:04:45 PM »
Bruce,
Any suggestions on what needs to be done to deal with the embed not being called when the link is clicked?

Thanks,
Mike