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: 

OO Excel: i_oi_spreadsheet invisible?

former_member185943
Participant
0 Kudos
1,128

Hi!

Is there a way to make the OO Excel object (class i_oi_spreadsheet) invisible and working without container? As far as I know, I must initialize control with a container (obligatory parameter). I am using a workaround: I pass default container CL_GUI_CONTAINER=>SCREEN0, so if I don't create any screen user sees nothing:

    DATA:
      lo_control       TYPE REF TO i_oi_container_control,
      lo_doc_proxy     TYPE REF TO i_oi_document_proxy,
      lo_spreadsheet   TYPE REF TO i_oi_spreadsheet.
*   create Excel document proxy
    c_oi_container_control_creator=>get_container_control(
           IMPORTING
             control              = lo_control ).
    lo_control->init_control(
             inplace_enabled      = 'X'
             r3_application_name  = 'EXCEL CONTAINER'
             parent               = cl_gui_container=>screen0 ).
    lo_control->get_document_proxy(
           EXPORTING
             document_type        = soi_doctype_excel_sheet
           IMPORTING
             document_proxy       = lo_doc_proxy ).

This works, but it is a workaround because container object is still created. Is there a proper way to make Excel object invisible?

I know that it is possible with old OLE2 interface:

SET PROPERTY OF e_appl 'VISIBLE' = 0.

Therefore, I think it should be possible with OO spreadsheet too.

Thanks!

KR,

Igor

6 REPLIES 6

Subhankar
Active Contributor
0 Kudos
345

Hi ,

If you used this class then you need to first create one container. But for invisible there is an option NO_flus. Check this fields. Check the sample code for the same.

form sub_create_container .

  • Create Instance control for container

call method c_oi_container_control_creator=>get_container_control

importing

control = iref_control

error = iref_error.

if iref_error->has_failed = c_check.

call method iref_error->raise_message

exporting

type = 'E'.

endif.

  • Create generic container linked to container in screen 100

create object oref_container

exporting

container_name = 'CONT'

exceptions

cntl_error = 1

cntl_system_error = 2

create_error = 3

lifetime_error = 4

lifetime_dynpro_dynpro_link = 5

others = 6.

if sy-subrc <> 0.

message e000 with 'Error while creating container'(012).

endif.

  • Establish connection to GUI Control

call method iref_control->init_control

exporting

inplace_enabled = c_check

r3_application_name = 'EXCEL CONTAINER'

parent = oref_container

importing

error = iref_error

exceptions

javabeannotsupported = 1

others = 2.

if iref_error->has_failed = c_check.

call method iref_error->raise_message

exporting

type = 'E'.

endif.

  • Create Document Proxy

call method iref_control->get_document_proxy

exporting

document_type = soi_doctype_excel_sheet

importing

document_proxy = iref_document

error = iref_error.

if iref_error->has_failed = c_check.

call method iref_error->raise_message

exporting

type = 'E'.

endif.

endform. " SUB_CREATE_CONTAINER

form sub_download_data_mult using p_index type sy-index.

data: l_row type i. " Number of rows

describe table <i_itab> lines l_row.

l_row = l_row + 1.

  • Populate the column heading

perform sub_pop_col_heading.

read table i_sheets into wa_sheets index p_index.

  • Selct sheet

call method iref_spreadsheet->select_sheet

exporting

name = wa_sheets-sheet_name

no_flush = c_check

importing

error = iref_error.

call method iref_spreadsheet->set_selection

exporting

top = 1

left = 1

rows = 1

columns = 1

no_flush = c_check

importing

error = iref_error.

call method iref_spreadsheet->insert_range

exporting

name = 'PRANGE'

rows = l_row

columns = v_col

no_flush = c_check

importing

error = iref_error.

  • Set the format of the cells

call method iref_spreadsheet->set_format

exporting

rangename = 'PRANGE'

typ = 0

currency = 'USD'

no_flush = 'X'

  • decimals = 2

importing

error = iref_error.

  • Get field names

call function 'DP_GET_FIELDS_FROM_TABLE'

tables

data = <i_itab>

fields = i_field_tab.

  • Insert records

call method iref_spreadsheet->insert_one_table

exporting

data_table = <i_itab>

fields_table = i_field_tab

rangename = 'PRANGE'

wholetable = c_check

no_flush = c_check

importing

error = iref_error.

  • Inser range for header

call method iref_spreadsheet->insert_range

exporting

name = 'COLOR'

rows = 1

columns = v_col

no_flush = c_check

importing

error = iref_error.

  • Set color for header

call method iref_spreadsheet->set_color

exporting

rangename = 'COLOR'

front = 5

back = 6

no_flush = c_check

importing

error = iref_error.

endform. " SUB_DOWNLOAD_DATA_MULT

Thanks

Subhanakr

Edited by: Subhankar Garani on Feb 25, 2010 10:06 AM

StMou
Active Participant
0 Kudos
345

Hi,

If you would like insert into your SAP application you must create a container CL_GUI_CONTAINER or used a docking container.

Rgds

0 Kudos
345

Hi!

Let me clarify my question some more: I would like to create an Excel file and download it to user's PC without ever showing it to the user. By "invisible" I mean really completely invisible, from first till the last line of the program, so that NO CONTAINER is ever needed. I can do it - my above code works. However, it's a workaround because I am still using the default container CL_GUI_CONTAINER=>SCREEN0 (which remains invisible because I never call screen), and I would like to avoid even this because I think it worsens performance.

KR,

Igor

0 Kudos
345

Hello Igor, did you find any solution? I'm in exactly the same situation.

I'm even trying creating a docking container and passing that instead of CL_GUI_CONTAINER=>SCREEN0, but calling CONTAINER->SET_VISIBLE( abap_false ) both before and after INIT_CONTROL, this changes nothing however, excel keeps popping up.

I also think the parameter SHELL_STYLE in INIT_CONTROL could help, but the include mentioned in SAP help does not exist:

 

shell_style

 

X

 

The display format of the container control in the R/3 screen Possible values are contained in the include <SAPOLECONTAINERCONTROL>. You do not normally have to change the default value of the parameter.

Hope you have a found a solution.

Regards

0 Kudos
345

Hi, Alejandro,

It was long time ago and don't remember well, but I think that I didn't find a solution.

KR,

Igor

0 Kudos
345

Thank you anyway Igor, because I rechecked your post and found out that you could indeed hide excel from showing, which was my problem.

The trick lies in this two things:

1. INIT_CONTROL: Send inplace_enabled = X AND parent = cl_gui_container=>screen0
2. OPEN_DOCUMENT: Send open_inplace = X

I was using screen0 but not inplace so excel was still showing.


I see now you wanted to go a step further and use no container at all, but indeed I think it's not possible since parent parameter in INIT_CONTROL is not optional.

Regards