on 06-19-2013 8:20 AM
Hi Experts,
Kindly help to achieve the export to excel functionality.
I’m able to export the internal data into excel using below code, but i need to add the CAPTION for every column in excel base on Internal table data.
if anyone can help out it would be greatly appreciated.
data LO_ND_SFLIGHT type ref to IF_WD_CONTEXT_NODE.
data LO_EL_SFLIGHT type ref to IF_WD_CONTEXT_ELEMENT.
data LT_SFLIGHT type WD_THIS->elements_sflight1.
data LS_SFLIGHT type WD_THIS->element_sflight1.
data TEXT type STRING.
data XTEXT type XSTRING.
* navigate from <CONTEXT> to <SFLIGHT> via lead selection
LO_ND_SFLIGHT = WD_CONTEXT->GET_CHILD_NODE( NAME = WD_THIS->wdctx_sflight1 ).
* get all declared attributes
LO_ND_SFLIGHT->GET_STATIC_ATTRIBUTES_TABLE(
importing
TABLE = LT_SFLIGHT ).
loop at LT_SFLIGHT into LS_SFLIGHT.
concatenate TEXT
LS_SFLIGHT-CARRID
LS_SFLIGHT-CONNID
LS_SFLIGHT-FLDATE
LS_SFLIGHT-CURRENCY
LS_SFLIGHT-PLANETYPE
CL_ABAP_CHAR_UTILITIES=>NEWLINE into TEXT separated by
CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
ENDLOOP.
call function 'SCMS_STRING_TO_XSTRING'
exporting
TEXT = TEXT
importing
BUFFER = XTEXT.
WDR_TASK=>CLIENT_WINDOW->CLIENT->ATTACH_FILE_TO_RESPONSE(
**path to the word file
I_FILENAME = 'WDP.xls'
* String Variable
I_CONTENT = XTEXT
* File Type
I_MIME_TYPE = 'EXCEL' ).
Thanks
AB
Anup,
before you loop lt_sflight table you can add the column headings to the variable TEXT where each column text is separated by tab. After the above step, go ahead with looping the table and add the table content to TEXT variable.
Hope this helps,
~Athreya
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Anup,
You would have to do something similar to what you are already doing to be able to download the column headers. Concatenate the desired column headers separated by horizontal tabs into a string variable say STR1. Now once you finish with your LOOP...ENDLOOP logic and arrive at the actual data in TEXT you can do another concatenate statement saying:
CONCATENATE STR1
TEXT into TEXT separated by CL_ABAP_CHAR_UTILITIES=>NEWLINE.
Then proceed with your calls to 'SCMS_STRING_TO_XSTRING' & ATTACH_FILE_TO_RESPONSE. Another word of advice here... You are not supposed to use any classes that start with WDR*. You should instead use: CL_WD_RUNTIME_SERVICES=> ATTACH_FILE_TO_RESPONSE.
Regards,
Uday
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
24 | |
12 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.