cancel
Showing results for 
Search instead for 
Did you mean: 

export to excel

former_member1193316
Participant
0 Kudos

hi,

i m having button called 'export'.

and a table having list of values.

when i click on the button 'export', all the table values should display in excel format. here i m not using alv's.

how to export to excel.plz guide me

thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi nirad, I am pretty close to your solution, could I contact you by email?

Thanks in advance!

former_member1193316
Participant
0 Kudos

Sorry to say, still i m facing the problem. wat u sent code, its not working for me.

plz guide me. its bit urgent to solve for me.

please

Former Member
0 Kudos

yaa my email address is nirad.p@gmail.com

Former Member
0 Kudos

wats probelm tell me we can solve it.

Nirad

Former Member
0 Kudos

hey jorge done with your export to excel stuff??

Former Member
0 Kudos

I got ur point .Now u have to follow this .Mind well i did this with ALV ,but logic should be the same apply this logic and i think u will get it.

1.If u r gonna working with individual cell .then create link to action in table cell I have given code here.


DATA: lr_link1 TYPE REF TO cl_salv_wd_uie_link_to_action.
lr_column = l_value->if_salv_wd_column_settings~get_column( 'CARRID' ).
CREATE OBJECT lr_link1.
lr_link1->set_text_fieldname( 'CARRID' ).
lr_link1->set_type( cl_wd_file_download=>e_type-result ).
lr_column->set_cell_editor( lr_link1 ).


* Display link in column connid
DATA: lr_link TYPE REF TO cl_salv_wd_uie_link_to_action.
lr_column = l_value->if_salv_wd_column_settings~get_column( 'CONNID' ).
CREATE OBJECT lr_link.
lr_link->set_text_fieldname( 'CONNID' ).
lr_link->set_type( cl_wd_file_download=>e_type-result ).
lr_column->set_cell_editor( lr_link ).

2.Now create method and register for the event when u click on cell and write following code there. You have to create node called event_properties and have 2 attributes name and values there.


data: lr_node type ref to if_wd_context_node,
  lt_event_properties type if_flight_list_view=>elements_event_properties,
  ls_event_properties type if_flight_list_view=>element_event_properties.
  field-symbols: <l_value> type any.

* fill internal table
  ls_event_properties-name = 'COLUMN_ID'.
  ls_event_properties-value = r_param->column.
  append ls_event_properties to lt_event_properties.

  ls_event_properties-name = 'INDEX'.
  ls_event_properties-value = r_param->index.
  append ls_event_properties to lt_event_properties.

  ls_event_properties-name = 'ATTRIBUTE'.
  ls_event_properties-value = r_param->attribute.
  append ls_event_properties to lt_event_properties.
  assign r_param->value->* to <l_value>.

  ls_event_properties-name = 'VALUE'.
  ls_event_properties-value = <l_value>.
  append ls_event_properties to lt_event_properties.


* navigate to context node EVENT_PROPERTIES
  lr_node = wd_context->get_child_node( 'EVENT_PROPERTIES' ).
* bind internal table to context node
  lr_node->bind_table( lt_event_properties ).

This way u can get the cell value.

now export this cell value to the memory id ,and from onactionexport() button, write the code that i have sent u (Rather than importing table ,import cell value there.)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi Nirad,

I am trying export my table data to excel file. I am trying to use your code in this thread but then I excel file doesn't open up. I am pretty new to WDA. Please guide me what am I missing.

Thanks

MLS

Former Member
0 Kudos

Hello Venkat,

You can always use the GUI_DOWNLOAD function module to export the contents of your table into excel file.

Regards,

Vasu

mohammed_anzys
Contributor
0 Kudos

Hi

I dont think GUI download will work in webdynpro.

Thanks

Anzy

Former Member
0 Kudos

I have attached the code for exporting the excel.If any problem revert back to me.


method ONACTIONON_EXPORT .

attach_files( i_only_one_file = abap_true i_in_new_window = abap_true i_inplace = abap_false ).

endmethod.


method ATTACH_FILES .
data:
      conv_out type ref to cl_abap_conv_out_ce,
      content  type xstring.


  data : itab_sflight type table of sflight.
  data: xml_out TYPE string.
*  data: conv_out type ref to cl_abap_conv_out_ce.
*  data: content type xstring.
*
*

*
  data:
    Node_Flight                         type ref to If_Wd_Context_Node,
    Elem_Flight                         type ref to If_Wd_Context_Element,
    Stru_Flight                         type ref to if_wd_context_element .



  import itab_sflight1 to itab_sflight  from MEMORY ID 'ZCA'.


  call transformation ('ID') source tab = itab_sflight[] result xml xml_out.


  CALL FUNCTION 'CRM_IC_XML_STRING2XSTRING'
    EXPORTING
      INSTRING         = xml_out
*
  IMPORTING
     OUTXSTRING       = content.

  conv_out = cl_abap_conv_out_ce=>create( encoding = 'UTF-8'  ).


  DATA: lv_filename TYPE string.


* attach the first file
  conv_out->convert( exporting data = xml_out IMPORTING buffer = content  ).
  cl_wd_runtime_services=>attach_file_to_response(
    i_filename  = 'Sales_order_release.xls'
    i_content   = content
    i_mime_type = 'application/msexcel'
    i_in_new_window = i_in_new_window
    i_inplace       = i_inplace ).
endmethod.