Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

i_oi_spreadsheet number of rows in Excel sheet.


I am using i_oi_spreadsheet interface to read content of Excel files. I have decided to use this interface, because I need to have access to several sheets defined in Excel file. Unfortunately method get_ranges_data which I used, requires to define range of data (cells) which will be read.

I can predict how many columns will be in each sheet, but I can not predict how many rows will be in each sheet.

Is there any way to read number of rows in each sheet in Excel file? Or any way to select all data in sheet?

Below I have add part of my code for reading content of sheets to show the way how I have done it for now.

DATA:  l_rows  TYPE i VALUE 30,

       l_cols  TYPE i VALUE 500.

CALL METHOD iref_spreadsheet->set_selection
           top     = 1
           left    = 1
           rows    = l_rows
           columns = l_cols.

CALL METHOD iref_spreadsheet->insert_range
           name     = 'Test'
           rows     = l_rows
           columns  = l_cols
           no_flush = ''
           error    = iref_error.
       IF iref_error->has_failed = 'X'.

CALL METHOD iref_spreadsheet->get_ranges_data
           all      = 'X'
           contents = lt_data       " in this table will be data from cells 30 x 500
           error    = iref_error
           ranges   = i_ranges.

Former Member

Helpful Answer

Not what you were looking for? View more on this topic or Ask a question