Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reading Smart Tables #1213

Closed
DarTas1 opened this issue Apr 18, 2024 Discussed in #1211 · 8 comments
Closed

Reading Smart Tables #1213

DarTas1 opened this issue Apr 18, 2024 Discussed in #1211 · 8 comments

Comments

@DarTas1
Copy link

DarTas1 commented Apr 18, 2024

Discussed in #1211

Originally posted by DarTas1 April 18, 2024
Hello,
looking for a way to read smart tables using abap2xlsx, but could not identify a way, since zcl_excel_reader loads the ZCL_EXCEL_WORKSHEET object without any information about tables. Tried to upload a generated version from ZDEMO_EXCEL3 and read it, but no info on the generated table was found in the runtime. Is there actually no possibility to read these tables from imported excel file or am I doing something wrong?
Code snippet with which I tried to check it:

SELECTION-SCREEN BEGIN OF BLOCK blx WITH FRAME.
PARAMETERS: p_upfile TYPE string LOWER CASE MEMORY ID gr8.
SELECTION-SCREEN END OF BLOCK blx.

DATA: excel          TYPE REF TO zcl_excel,
      reader         TYPE REF TO zif_excel_reader,
      worksheet      TYPE REF TO zcl_excel_worksheet,
      lt_files       TYPE filetable,
      lv_rc          TYPE i,
      lv_file_filter TYPE string.

lv_file_filter = 'Excel Files (*.XLSX;*.XLSM)|*.XLSX;*.XLSM'.
cl_gui_frontend_services=>file_open_dialog( EXPORTING
                                              default_filename        = p_upfile
                                              file_filter             = lv_file_filter
                                            CHANGING
                                              file_table              = lt_files
                                              rc                      = lv_rc
                                            EXCEPTIONS
                                              OTHERS                  = 1 ).
READ TABLE lt_files INDEX 1 INTO p_upfile.

CREATE OBJECT reader TYPE zcl_excel_reader_2007.
excel = reader->load_file( i_filename = p_upfile ).

worksheet = excel->get_active_worksheet( ).

write: 'size of tables ', worksheet->get_tables_size( ).

Result is always 0
image
Used the file:
generated table.xlsx

BR,
Dartas1

@darnoc312
Copy link
Contributor

darnoc312 commented Apr 19, 2024

Hello,
are you using an ABAP2XLSX with the changes of pull request #1159 ? If you do not this is always the result.
In according issue #1158 the same symptom was described.

@sandraros
Copy link
Collaborator

@darnoc312 Thanks, I couldn't find it.

@sandraros
Copy link
Collaborator

@DarTas1 Sorry to mislead you, in fact this issue was already fixed, as @darnoc312 said. Is it okay to close this issue?

@DarTas1
Copy link
Author

DarTas1 commented Apr 27, 2024

I have pulled the latest version of the project. The example code indeed shows the count correctly, but inside no information on values of the cells.

@DarTas1 DarTas1 closed this as completed Apr 27, 2024
@DarTas1 DarTas1 reopened this Apr 27, 2024
@sandraros
Copy link
Collaborator

@DarTas1 Currently your question refers to the old issue which is solved. If I understand well your point about "no information on values of the cells", it doesn't refer to a bug but to a feature request like creating a kind of get_data public method in the class zcl_excel_table. Remember that the attribute table_data of zcl_excel_table is private.

@DarTas1
Copy link
Author

DarTas1 commented Apr 29, 2024

table data attribute contains found cells, but the values, even though they should contain something, are empty.
image
is the one im trying to read.
In debugger looks very promising. (except for name which is not there)
image
but sadly no values
image

@sandraros
Copy link
Collaborator

Yes exactly. But I told you that this attribute is PRIVATE, it's internal, you can't use it in your ABAP code, it's not intended to be used.
So, again, it's not a bug, it's a feature request like creating a kind of get_data (public method) in the class zcl_excel_table.
I just want you to confirm, thank you.

NB: just to clarify what is in my mind, in the solution, I want the attribute to remain private and empty, only the method get_data would be able to fill your own internal table (not table_data).

@DarTas1
Copy link
Author

DarTas1 commented Apr 29, 2024

thanks for clarification. then it is all good ;)

@DarTas1 DarTas1 closed this as completed Apr 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants