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: 

How to identify and get data of a specific table from an Excel file into a generic table

hamida_ashna
Explorer
0 Kudos
823

I have to make a program that could read data of a specific table via table name from Excel file. Now I am confused about how to identify that table from an Excel file. I looked through the abap2xlsx project, but I didn't find any method for identifying a specific table through the table name.

If somebody could give me some advice, that would be great. Thanks in advance.

8 REPLIES 8

Sandra_Rossi
Active Contributor
651

There are lots of methods in abap2xlsx to extract the texts from an Excel file.

After that, storing these texts in an internal table, and in a database table, is easy.

hamida_ashna
Explorer
0 Kudos
651

sandra.rossi, thanks for your reply. But, can you please give me more information about it.

- For example, in the below sheet I have 6 tables. But, I want to read or extract only the data of "PriceList" table, not the others. So, how can I do this?

Sandra_Rossi
Active Contributor
0 Kudos
651

I don't know what you have understood from abap2xlsx, but reading the cells below "PriceList" is basically simple:

sheet->get_table(
    EXPORTING
        iv_skipped_rows = 3
        iv_skipped_cols = 8
        iv_max_col      = 10
        iv_max_row      = 10
    IMPORTING
        et_table        = table_interne ).

hamida_ashna
Explorer
0 Kudos
651

Yeah, you are right. With "get_table" I can read it. But how should I set values for these 4 parameters "iv_skipped_rows", "iv_skipped_cols", "iv_max_col", and "iv_max_row".

As you can see in the above image. I should have these 2 parameters in my program. And based on the entry table name, the program should read data of that specific table. Now if I use "get_table", so how should I find values of these parameters dynamically "iv_skipped_rows", "iv_skipped_cols", "iv_max_col", and "iv_max_row".

Sandra_Rossi
Active Contributor
0 Kudos
651

Unless you want to use Artificial Intelligence, it's where human beings must be educated to place the information always at the same position in the Excel file otherwise the program can't work well.

Sandra_Rossi
Active Contributor
0 Kudos
651

Keep it simple.

Do a GET_TABLE of all cells to fill an internal table, and then apply the logic you want on this internal table.

hamida_ashna
Explorer
0 Kudos
651

Sandra Rossi, thanks a lot for your advice.

Sandra_Rossi
Active Contributor
0 Kudos
651

If you have this worksheet, and you want to read the cells below "PriceList" (columns I to K = 9 to 11, rows 4 to 10)

Do this code with abap2xlsx:

sheet->get_table(
    EXPORTING
        iv_skipped_rows = 3
        iv_skipped_cols = 8
        iv_max_col      = 11
        iv_max_row      = 10
    IMPORTING
        et_table        = price_list ).