cancel
Showing results for 
Search instead for 
Did you mean: 

regarding file format conversion

0 Kudos

i got a requirement to upload and download excel file into webdynpro alv table.by default export to excel is available but the file downloading is in xls format instead of xlsx format.how to overcome this. and i need to upload the xlsx file after doing some changes in the downloaded file.how to convert file format from xls to xlsx.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

i got the solution for this.

when we click on export to excel button in alv it will download the data into excel file with format(XLS) to download the file into (XLSX) format we need to maintain some entry for the field export_format of table salv_wd_admin(export_format field value = 10) then the std export to excel button  in alv table download the data in excel file with format(XLSX).

we need to maintain the value in TMG(table maintenance Generator)/through spro settings.

Answers (1)

Answers (1)

santhu_gowdaz
Active Contributor
0 Kudos
0 Kudos

hi santhosh,

thanks for the quick response.

the thing is that if i download the data using export to excel which is std functionality file format is in .XLS format and now we are using office 2010 where the format is .XLXS i need to convert .xls to .xlxs.

former_member197475
Active Contributor
0 Kudos

Hi Rama,

Why can't you go ahead for your custom button, and make your own format wish of your download option.

As you told that you are working in a standard function, just try to hide the button and create your custom button. It will be a better approach for your requirement.

BR,

RAM.

0 Kudos

i am trying that one but the thing is how to pass the file format xlsx to cl_wd_runtime_services->attach_file_to_response. it is not allowing.

former_member197475
Active Contributor
0 Kudos

Hi Rama,

Just call the method and pass the below values.

cl_wd_runtime_services=>attach_file_to_response(

    EXPORTING i_filename      = 'download.xlsx'    "Name/type of excel

              i_content       = lv_xstring   "Your values

              i_mime_type     = 'EXCEL'

              i_in_new_window = abap_false ).

Try it out.

BR,

RAM.

0 Kudos

hi

thanks for the response. i tried that one but the file is downloading in .xls format eventhough i provided .xlsx extension

former_member197475
Active Contributor
0 Kudos

Hi Rama,

It would be best, if you please share your piece of code.

BR,

RAM.

0 Kudos

  DATA lo_nd_sflight_node TYPE REF TO if_wd_context_node.

  DATA lt_sflight_node TYPE wd_this->elements_sflight_node.

* navigate from <CONTEXT> to <SFLIGHT_NODE> via lead selection

  lo_nd_sflight_node = wd_context->get_child_node( name = wd_this->wdctx_sflight_node ).

* @TODO handle non existant child

* IF lo_nd_sflight_node IS INITIAL.

* ENDIF.

  lo_nd_sflight_node->get_static_attributes_table( IMPORTING table = lt_sflight_node ).

  DATA :  ls_sflight_node like line of lt_sflight_node,

          lv_text type string.

LOOP at lt_sflight_node into ls_sflight_node.

  CONCATENATE lv_text

        ls_sflight_node-MANDT

        ls_sflight_node-CARRID

        ls_sflight_node-CONNID

        ls_sflight_node-FLDATE

*        ls_sflight_node-PRICE

*        ls_sflight_node-CURRENCY

*        ls_sflight_node-PLANETYPE

*        ls_sflight_node-SEATSMAX

*        ls_sflight_node-SEATSOCC

*        ls_sflight_node-PAYMENTSUM

*        ls_sflight_node-SEATSMAX_B

*        ls_sflight_node-SEATSOCC_B

*        ls_sflight_node-SEATSMAX_F

*        ls_sflight_node-SEATSOCC_F

cl_abap_char_utilities=>newline

INTO lv_text

SEPARATED BY cl_abap_char_utilities=>horizontal_tab.

CLEAR ls_sflight_node.

ENDLOOP.

DATA : lv_xstring TYPE xstring.

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

  EXPORTING

    text           = lv_text

*   MIMETYPE       = ' '

*   ENCODING       =

IMPORTING

   BUFFER         = lv_xstring

* EXCEPTIONS

*   FAILED         = 1

*   OTHERS         = 2

          .

IF sy-subrc <> 0.

* Implement suitable error handling here

ENDIF.

data : lv_clientwindow type ref to CL_WDR_CLIENT_WINDOW.

lv_clientwindow = WDR_TASK=>CLIENT_WINDOW.

data : lv_client type ref to IF_WDR_CLIENT.

lv_client = lv_clientwindow->client.

CALL METHOD lv_client->attach_file_to_response

  EXPORTING

    i_filename      = 'rk.xlsx'

    i_content       = lv_xstring

    i_mime_type     = 'EXCEL'

*    i_compression   = IF_HTTP_ENTITY=>CO_COMPRESS_BASED_ON_MIME_TYPE

*    i_in_new_window = ABAP_FALSE

*    i_inplace       = ABAP_FALSE

    .

please find the code

former_member197475
Active Contributor
0 Kudos

Hi Rama,

This code won't work, as this works only for XLS format.

If we need to try for XLSX format, first create the document with reference to the available data using method cl_fdt_xl_spreadsheet=>if_fdt_doc_spreadsheet~create_document, which will directly convert your input compatible to .XLSX xstring and then try to call cl_wd_runtime_services=>attach_file_to_response. It will work for sure.

Please find the below document for your reference.

BR,

RAM.

0 Kudos

i am working with the create document method itself but i am not able to pass the headings for the columns.this is where i am strucking.let me know if there is any possibility to pass headings for columns.