Web and Microsoft Excel

This Q&A forum allows users to post and respond to "How Do I Do ....." questions. Please do not use to report (suspected) errors - you must use your regional help desk for this. The information contained in this forum has not been validated by LANSA and, as such, LANSA cannot guarantee the accuracy of the information.
Post Reply
Joerg Hamacher
Posts: 124
Joined: Thu Feb 11, 2016 12:01 am

Web and Microsoft Excel

Post 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
Joerg Hamacher
Posts: 124
Joined: Thu Feb 11, 2016 12:01 am

Re: Web and Microsoft Excel

Post 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
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Web and Microsoft Excel

Post 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
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
User avatar
Stewart Marshall
Posts: 417
Joined: Thu Nov 05, 2015 5:25 pm

Re: Web and Microsoft Excel

Post 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
Stewart Marshall

Independent IT Consultant
www.marshallfloyd.com.au
Post Reply