Page 1 of 1

Web and Microsoft Excel

Posted: Thu Sep 22, 2016 9:16 pm
by Joerg Hamacher
Hi,

when working with web pages Built-In-Function TRANSFORM_LIST is not available (Commend USE is not supported on Web).
Customer wants to save data that is displayed in a ListView on the webpage as a CSV file.
Is this possible? And if, how?

And in this context: they want to open a Microsoft Word document directly from the webpage. Can this be managed?

Many thanks in advance,
Joerg

Re: Web and Microsoft Excel

Posted: Thu Sep 22, 2016 10:56 pm
by Joerg Hamacher
Hi again,

I found a solution for this issue. USE command can be used in ServerModules and so there is one routine to create the file on the server and a second routine to manage the download:

Srvroutine Name(CreateCSV)
List_Map For(*INPUT) List(#WListEmployees)
Field_Map For(*OUTPUT) Field(#IO$STS)
#STD_QSEL := *PART_DIR_OBJECT + 'WListEmployees.csv'
Use Builtin(TRANSFORM_LIST) With_Args(#WListEmployees #STD_QSEL B B Y '.') To_Get(#IO$STS)
Endroutine

Srvroutine Name(DownloadCSV) Response(#Response)
#Response.ContentFile := *PART_DIR_OBJECT + 'WListEmployees.csv'
#Response.AttachmentFileName := 'SelectedEmployees.CSV'
Endroutine

I think this will work this way - but does anybody know how to open a word document from a webpage?

Joerg

Re: Web and Microsoft Excel

Posted: Fri Sep 23, 2016 8:39 am
by Stewart Marshall
Hi Joerg

Sadly, your customer is going to be disappointed. Browsers only allow objects to be downloaded, and only provide access to the local file system in very limited circumstances. This is why Transform_list is not available

If a browser could automatically download and execute an .exe, security would be greatly compromised.

The download solution you've suggested for a CSV is the best you can do.

Regards

Re: Web and Microsoft Excel

Posted: Fri Sep 23, 2016 12:16 pm
by Stewart Marshall
One more thing, there's no need to have two routines. You can send the list and download in a single call to the server

Code: Select all

Srvroutine Name(DownloadCSV) Response(#Response)
List_Map For(*Input) List(#EmployeesCSV)

Define_Com Class(#Prim_alph) Name(#FileName)

#FileName := *PART_DIR_OBJECT + Employees + ".csv"

Use Builtin(TRANSFORM_LIST) With_Args(#EmployeesCSV #FileName O B) To_Get(#IO$STS)

#Response.ContentFile := #FileName
#Response.AttachmentFileName := "Employees.CSV"
#Response.RemoveFile := true

Endroutine

Note that the response object is flagged as RemoveFile True. This will ensure that the file created is immediately deleted

Regards