on 2018 Dec 03 10:41 AM
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 ).
Help others by sharing your knowledge.
AnswerRequest clarification before answering.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
73 | |
18 | |
10 | |
9 | |
7 | |
4 | |
4 | |
4 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.