Quantcast
Channel: SCN: Message List
Viewing all articles
Browse latest Browse all 8533

Re: Excel file upload to CRM

$
0
0

Hello Nisha,

 

thanks for your reply to my question. Unfortuatelly the snippet you postet is not very helpful for me. I already realized the part with the GUI upload before but in the internal table is only some unprocessable ascii code source text of the XLS. I'm looking for a method to convert this code mash into a processable internal table which represents the line and column structure of the excel worksheet.

 

Yesterday I made some experiments with the class CL_XLSX_DOCUMENT. It seems to have a few helpful methods but I wasn't able to really extract some processable information. Here the coding which i wrote:

 

DATA source_line  TYPE c LENGTH 80.
 DATA source_table LIKE TABLE OF source_line.
 DATA buffer TYPE xstring.
 DATA filelength TYPE i.
 DATA lr_excel_doc TYPE REF TO cl_xlsx_document.
 DATA lr_wb_part TYPE REF TO cl_xlsx_workbookpart.
 DATA lr_ws_parts TYPE REF TO cl_openxml_partcollection.
 DATA lr_part TYPE REF TO cl_xlsx_worksheetpart.
 DATA lr_table_parts TYPE REF TO cl_openxml_partcollection .
 TRY.     CALL FUNCTION 'GUI_UPLOAD'       EXPORTING         filename                = 'C:\Example.xlsx'         filetype                = 'BIN'       IMPORTING         filelength              = filelength       TABLES         data_tab                = source_table       EXCEPTIONS         file_open_error         = 1         file_read_error         = 2         no_batch                = 3         gui_refuse_filetransfer = 4         invalid_type            = 5         no_authority            = 6         unknown_error           = 7         bad_data_format         = 8         header_not_allowed      = 9         separator_not_allowed   = 10         header_too_long         = 11         unknown_dp_error        = 12         access_denied           = 13         dp_out_of_memory        = 14         disk_full               = 15         dp_timeout              = 16         OTHERS                  = 17.     CALL FUNCTION 'SCMS_BINARY_TO_XSTRING'       EXPORTING         input_length = filelength       IMPORTING         buffer       = buffer       TABLES         binary_tab   = source_table       EXCEPTIONS         failed       = 1         OTHERS       = 2.     lr_excel_doc =  cl_xlsx_document=>load_document( buffer ).   CATCH cx_root.
 ENDTRY.
 TRY .     lr_wb_part = lr_excel_doc->get_workbookpart( ).   CATCH cx_openxml_format cx_openxml_not_found.
 ENDTRY.
 TRY .     lr_ws_parts = lr_wb_part->get_worksheetparts( ).   CATCH cx_openxml_format.
 ENDTRY.
 lr_part ?= lr_ws_parts->get_part( 0 ).
 TRY.     lr_table_parts = lr_part->get_tableparts( ).   CATCH cx_openxml_format.       CATCH cx_openxml_not_found.    
 ENDTRY.
 lv_data = lr_part->get_data( ).

Do you have some experience with the class CL_XLSX_DOCUMENT?

 

Best regards,

Markus


Viewing all articles
Browse latest Browse all 8533

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>