cancel
Showing results for 
Search instead for 
Did you mean: 

Download excel with multiple sheets using Transformation

sankar1781
Participant
0 Kudos
1,485

Hi Experts,

I have a requirement to download the data into an excel file with multiple/two sheets.

I followed the blog "Internal to Excel with multiple sheets and formatting" and just changed only the below area.

    ls_xls_cell-styleid 'Default'.
    CLEAR ls_xls_cell-cell_content.
    ls_xls_cell-type 'String'.
    ls_xls_cell-cell_content lv_ftext.  "fieldnames
    APPEND ls_xls_cell TO ls_xls_row-cells.

    ls_xls_cell-styleid = 'Default'.
    CLEAR ls_xls_cell-cell_content.
    ls_xls_cell-type 'String'.
    ls_xls_cell-cell_content = lv_vtext. "fieldvalues
    APPEND ls_xls_cell TO ls_xls_row-cells.

Rest are all same but I am getting the downloaded file data as shown in the image.

Where I run the blog help program, I can see the output as in the blog i.e., Excel sheet with multiple rows and multiple sheets (Sheet 1 and Sheet 2). Whereas I am getting an incorrect one.

Please help.

Thanks in advance.

sankar1781_0-1706470588767.png

 

Accepted Solutions (0)

Answers (1)

Answers (1)

Sandra_Rossi
Active Contributor
0 Kudos

To write to several cells, you must use one APPEND to the internal table per cell.

    ls_xls_cell-cell_content = fieldname_1.
    APPEND ls_xls_cell TO ls_xls_row-cells. " column A

    ls_xls_cell-cell_content = fieldname_2.
    APPEND ls_xls_cell TO ls_xls_row-cells. " column B

    ls_xls_cell-cell_content = fieldname_3.
    APPEND ls_xls_cell TO ls_xls_row-cells. " column C

What you did is to write to only one cell (i.e. only one APPEND), with field names separated with a horizontal tabulation, which writes all the field names into the same cell, not in several cells.

Concerning your issue about only one sheet being generated, I cannot reproduce, my program (based on yours with all non-compiling stuff removed) generates two sheets successfully.