cancel
Showing results for 
Search instead for 
Did you mean: 

Generate Excel Template file in application server for downloading in UI5

agrawalaadhar8
Participant
0 Kudos
3,559

Hi All,


I need to download an excel template file on click of a download button in front-end.

I am calling my service using 'POST' and in back-end in the DPC_EXT CLASS~GET_STREAM method I am creating a file.

The problem is I am getting a tab delimited file instead of a proper excelsheet.

I require one header row(which shows the headings for columns) for around 50 columns in template.

No other data needs to be present in the excel.

Please help on how I can generate an excel file instead of delimited files.

Thanks!

Code:

DATA conv TYPE REF TO cl_abap_conv_out_ce.

CONCATENATE text-G01 text-G02 text-G03 text-G04 text-G05 text-G06 INTO f_data-data.
REPLACE ALL OCCURRENCES OF ',' IN f_data-data WITH cl_abap_char_utilities=>horizontal_tab.

conv = cl_abap_conv_out_ce=>create( encoding = 'UTF-8' endian = 'L' ).
conv->convert( EXPORTING data = f_data-data IMPORTING buffer = ls_stream-value ).

ls_header-name = 'Content-Disposition'.  
ls_stream-mime_type = 'application/vnd.ms-excel'.

CONCATENATE 'attachment; filename=' 'TEMPLATE.xls' INTO ls_header-value.
me->set_header( is_header = ls_header ).
View Entire Topic
agrawalaadhar8
Participant
0 Kudos

Hi there is a new challenge I am facing now..

When this XLSX template file is uploaded I need to split the details of each column into a variable.

If this was CSV it would work fine, but I have multi-lingual characters and CSV doesn't understand and convert them to '?????'.

So how do I read the uploaded file in the application server.

I think I am receiving the file in XSTRING type in CREATE_STREAM method.

Please advise.

Thanks a lot

DoanManhQuynh
Active Contributor
0 Kudos

I think if you got ???? after upload its mean your system dont have that font so you may try to install font first. btw, you should close thread after get the answer and open new one for new issue