on 05-29-2014 7:57 PM
Hi Experts,
I have just followed the steps from below blog for uploading data from webdynpro internal table to EXCEL.
http://webdynproabap.wordpress.com/2012/10/08/exporting-to-excel-sheet/
Of-course every thing is working fine. But the data alignment in Excel is not good. As the entire record values are shown up in a straight line. So am getting a single row in excel being filled with all table records
Did anyone faced the same problem?
Also is there any possibility to add Column name in the excel.
Please help out me.
BR,
RAM.
Hi Ramakrishnan,
Check Below code what i've done in my development.
DATA: LV_TEXT_056 TYPE STRING,
LV_TEXT_057 TYPE STRING,
LV_TEXT_058 TYPE STRING,
LV_TEXT_059 TYPE STRING,
LV_TEXT_060 TYPE STRING,
LV_TEXT_061 TYPE STRING,
LV_TEXT_062 TYPE STRING.
IF LT_PDF IS NOT INITIAL.
*--------->Getting Header text
LV_TEXT_056 = WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( '056' ).
LV_TEXT_057 = WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( '057' ).
LV_TEXT_058 = WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( '058' ).
LV_TEXT_059 = WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( '059' ).
LV_TEXT_060 = WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( '060' ).
LV_TEXT_061 = WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( '061' ).
LV_TEXT_062 = WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( '062' ).
*----------->Collecting Header information
CONCATENATE LV_TEXT_056 LV_TEXT_057 LV_TEXT_058 LV_TEXT_059 LV_TEXT_060 LV_TEXT_061
LV_TEXT_062 CL_ABAP_CHAR_UTILITIES=>NEWLINE
INTO LW_TEXT SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
*---------->Collecting Data
LOOP AT LT_PDF INTO LS_PDF.
CONCATENATE LW_TEXT LS_PDF-CATG INTO LW_TEXT.
CONCATENATE LW_TEXT
LS_PDF-DOA_CODE LS_PDF-DOA_TEXT LS_PDF-DOA_LEVEL
LS_PDF-DOA_LEVEL_TEXT LS_PDF-DOA_VALUE_LIMIT LS_PDF-DELEGATABLE
CL_ABAP_CHAR_UTILITIES=>NEWLINE INTO LW_TEXT
SEPARATED BY CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB.
CLEAR:LS_PDF.
ENDLOOP.
*-------->Converting string to Xstring
CALL FUNCTION 'SCMS_STRING_TO_XSTRING'
EXPORTING
TEXT = LW_TEXT
MIMETYPE = ' '
* ENCODING =
IMPORTING
BUFFER = LX_TXT
EXCEPTIONS
FAILED = 1
OTHERS = 2.
IF SY-SUBRC <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
*---------------->Creating Excel file
LV_TEXT_062 = WD_ASSIST->IF_WD_COMPONENT_ASSISTANCE~GET_TEXT( '063' ).
CALL METHOD CL_WD_RUNTIME_SERVICES=>ATTACH_FILE_TO_RESPONSE
EXPORTING
I_FILENAME = LV_TEXT_062
I_CONTENT = LX_TXT
I_MIME_TYPE = 'EXCEL'.
* I_IN_NEW_WINDOW = ABAP_FALSE
* I_INPLACE = ABAP_FALSE
Regards,
Jack.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Jack,
Thanks for your help.
I have found the reason that CL_ABAP_CHAR_UTILITIES=>NEWLINE or CL_ABAP_CHAR_UTILITIES=>HORIZONTAL_TAB is not being recognized in my system. Either I want to go for a SP upgrade or I need to implement the note 1813468.
But still am not sure for those remedies. Any ideas?
BR,
RAM.
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
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.