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: 

Excel using OLE : Protect cells and insert rows

former_member206377
Active Contributor
0 Kudos

Hi All,

I am downloading an excel from an ABAP program using OLE automation.

I am protecting few cells in the excel (not the entire sheet) but this does not allow me to insert rows in the excel.

How can we protect few cells as well as insert rows in the sheet?

Or, as an alternative is it possible to set the cells as invisible ? How do we set the 'invisible' property for selected range of cells?

Though, this issue is already discussed in SDN i could'nt find solution for the same.

Kinldy help me with your inputs.

Thanks ,

Vasuki

3 REPLIES 3

Former Member
0 Kudos

Hi.. Vasuki

You can create a range for few cells using the method insert_ranges and protect the range against input

using the method protect_range.

These methods are from the interface I_OI_SPREADSHEET.

Thanks,

Sandhya.

0 Kudos

Hi Sandhya,

Thanks for the reply. I am using OLE to generate the excel adn fill data into it. How can i use PROTECT_RANGES method in this context? Can you pls help me with a sample code for the same?

Thanks,

Vasuki

0 Kudos

Vasuki..

Here's the code.

**Create a range called ROUTES.

data : spreadsheet TYPE REF TO i_oi_spreadsheet.

l_w_ranges-name = 'ROUTES'.

l_w_ranges-top = 8.

l_w_ranges-left = 1.

l_w_ranges-rows = rows_number.

l_w_ranges-columns = 7.

APPEND l_w_ranges TO l_t_ranges.

CLEAR l_w_ranges.

CALL METHOD spreadsheet->insert_ranges

EXPORTING ranges = l_t_ranges

no_flush = 'X'

IMPORTING error = error

retcode = retcode.

**Protect the range.

CALL METHOD spreadsheet->protect_range

EXPORTING name = 'ROUTES'

protect = 'X'

no_flush = 'X'

IMPORTING error = errors.

APPEND errors.

Thanks,

Sandhya.