Skip to Content

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

i_oi_spreadsheet number of rows in Excel sheet.

Hello.

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
         EXPORTING
           top     = 1
           left    = 1
           rows    = l_rows
           columns = l_cols.

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


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

Tags:
Former Member

Helpful Answer

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