Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

problem with long text when uploading xlsx in sap

former_member2492
Active Participant
0 Kudos

Greetings,

I'm trying to upload an xlsx file using the following code,

my excel has 3 rows 3 columns ,the last column has a long text and is empty in gt_data.,it does not get populated.only the last column.

Can someone help me?

 DATA : lo_excel_ref TYPE REF TO cl_fdt_xl_spreadsheet .

  TRY .

       lo_excel_ref = NEW cl_fdt_xl_spreadsheet(<br>

                                document_name = l_filename<br> 

                               xdocument     = lv_headerxstring ) .<br>

      CATCH cx_fdt_excel_core.<br>

        "Implement suitable error handling here<br>

    ENDTRY .<br><br>  

  "Get List of Worksheets<br> 

   lo_excel_ref->if_fdt_doc_spreadsheet~get_worksheet_names(<br> 

     IMPORTING<br>      

  worksheet_names = DATA(lt_worksheets) )

.<br><br><br>    IF NOT lt_worksheets IS INITIAL.<br> 

     READ TABLE lt_worksheets INTO DATA(lv_woksheetname) INDEX 1.<br><br> 

     DATA(lo_data_ref) =<br> 

     lo_excel_ref->if_fdt_doc_spreadsheet~get_itab_from_worksheet(<br>  
 lv_woksheetname ).<br>   

   "now you have excel work sheet data in dyanmic internal table<br> 

     ASSIGN lo_data_ref->* TO <gt_data>.<br>

   ENDIF.
17 REPLIES 17

former_member2492
Active Participant
0 Kudos

I've tried to use alsm_excel_to_internal_table it also gives me upload_ole error

raymond_giuseppi
Active Contributor

Can you try to display the data actually read by the class

ASSIGN lo_data_ref->* TO FIELD-SYMBOL(<fs_worksheet_data>).
cl_demo_output=>write_data( <fs_worksheet_data> ). DATA(lv_html) = cl_demo_output=>get( ). cl_abap_browser=>show_html( EXPORTING title = 'Excel-Worksheet' ##NO_TEXT html_string = lv_html container = cl_gui_container=>default_screen ).

0 Kudos

as you can see the third column is empty

0 Kudos

raymond.giuseppi when I try to upload usong ALSM_EXCEL_TO_INTERNAL_TABLE

it gives me the upload_ole error.I am calling it from my fiori app. Can you help me with a solution?

that function will NOT work in background, since it needs a connection to the GUI (hence the OLE error)

You could try using abap2xlsx for reading.

0 Kudos

andreaborgia what about the oo aproach as above? the only problem it doest read the long text in my third column.as you can see in the picture.

0 Kudos

I have no idea what your code does, since it is now one long line and I can't read it 🙂

That said, abap2xlsx is as OO as it gets... the demo for reading is ZDEMO_EXCEL15

I've fixed it!can you please read it now?

0 Kudos

I've seem that when I remove the formating of that column,simple text now,its okay. somehow when its formated it doesnt work

Ok, at the moment in abap2xlsx there is no method to extract a table from the worksheet, you'll have to do it row by row, column by column as in the example I gave you but it's being planned for a future release.

It is therefore a limitation of the class. (Read also 2468709 - Usage of standard class CL_FDT_XL_SPREADSHEET, it's not a generic tool but was intended for decision table in BRFplus workbench)

Sandra_Rossi
Active Contributor
0 Kudos

What is your question, what issue do you have?

former_member2492
Active Participant
0 Kudos

sandra.rossi its written there...can you read it?

Sandra_Rossi
Active Contributor
0 Kudos

Now that you added it to your question, I can read it 😉

Sandra_Rossi
Active Contributor
0 Kudos

By the way, not your fault (thanks to SAP Community), the formatting of your code is gone with your edit.

Sandra_Rossi
Active Contributor

If it's a bug from cl_fdt_xl_spreadsheet, then you should look at SAP notes, or contact SAP support.

Otherwise, you can use abap2xlsx (at least it works).

former_member2492
Active Participant
0 Kudos

sandra.rossi thank you ,I too just found it out.do you know another class to use apart abap2xls?