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
Web and Microsoft Excel
-
Joerg Hamacher
- Posts: 124
- Joined: Thu Feb 11, 2016 12:01 am
Re: Web and Microsoft Excel
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
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
- Stewart Marshall
- Posts: 417
- Joined: Thu Nov 05, 2015 5:25 pm
Re: Web and Microsoft Excel
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
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
- Stewart Marshall
- Posts: 417
- Joined: Thu Nov 05, 2015 5:25 pm
Re: Web and Microsoft Excel
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
Note that the response object is flagged as RemoveFile True. This will ensure that the file created is immediately deleted
Regards
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
Regards