Application Development and Automation 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: 
Read only

Regarding OLE object

Former Member
0 Likes
695

Hi all,

I am using OLE objects to move data to 5 sheets in a single XL file.

my problems are ,

1.It is taking more time to get execute. so is there any way to reduce the time ?

2.Whether it is possible to ececute this report ( created using ole objects ) in background ?

pls help reg this.

1 ACCEPTED SOLUTION
Read only

Former Member
0 Likes
651

ad 2. No, OLE requires direct link to desktop.

Regards,

John.

5 REPLIES 5
Read only

Former Member
0 Likes
652

ad 2. No, OLE requires direct link to desktop.

Regards,

John.

Read only

Former Member
0 Likes
651

Hi all,

is there any way to download data to excel in background.

pls help reg this.

Read only

0 Likes
651

You can use FM GUI_DOWNLOAD

Read only

Former Member
0 Likes
651

For reducing time u can do one thing....

after generation of all the 5 sheet... u put display on for the excel. Actuall I have for single excel sheet... and reduces time by this way....

Can u pls send the code for feature reference.....

Read only

0 Likes
651

&----


*& Report ZTEST55

*&

&----


*&

*&

&----


REPORT ZTEST55.

INCLUDE ole2incl.

DATA: application TYPE ole2_object,

workbook TYPE ole2_object,

sheet TYPE ole2_object,

cells TYPE ole2_object.

CONSTANTS: row_max TYPE i VALUE 256.

DATA index TYPE i.

DATA: BEGIN OF itab1 OCCURS 0, first_name(10), END OF itab1.

DATA: BEGIN OF itab2 OCCURS 0, second_name(10), END OF itab2.

DATA: BEGIN OF itab3 OCCURS 0, third_name(50), END OF itab3.

DATA: BEGIN OF itab4 OCCURS 0, fourth_name(50), END OF itab4.

DATA: BEGIN OF itab5 OCCURS 0, fifth_name(50), END OF itab5.

************************************************************************

*START-OF-SELECTION

START-OF-SELECTION.

APPEND: 'Peter' TO itab1, 'Ivanov' TO itab2,

'=Sheet1!A1 & " " & Sheet2!A1' TO itab3,

'John' TO itab1, 'Smith' TO itab2,

'=Sheet1!A2 & " " & Sheet2!A2' TO itab3.

append : 'fourth_arun' to itab4.

CREATE OBJECT application 'excel.application'.

SET PROPERTY OF application 'visible' = 1.

CALL METHOD OF application 'Workbooks' = workbook.

CALL METHOD OF workbook 'Add'.

*Create first Excel Sheet

CALL METHOD OF application 'Worksheets' = sheet

EXPORTING #1 = 1.

CALL METHOD OF sheet 'Activate'.

SET PROPERTY OF sheet 'Name' = 'First'.

LOOP AT itab1.

index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name

CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.

SET PROPERTY OF cells 'Value' = itab1-first_name.

ENDLOOP.

*Create second Excel sheet

CALL METHOD OF application 'Sheets' = sheet.

CALL METHOD OF sheet 'Add'.

CALL METHOD OF application 'Worksheets' = sheet

EXPORTING #1 = 1.

SET PROPERTY OF sheet 'Name' = 'Second'.

CALL METHOD OF sheet 'Activate'.

LOOP AT itab2.

index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name

CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.

SET PROPERTY OF cells 'Value' = itab2-second_name.

ENDLOOP.

*Create third Excel sheet

CALL METHOD OF application 'Sheets' = sheet.

CALL METHOD OF sheet 'Add'.

CALL METHOD OF application 'Worksheets' = sheet

EXPORTING #1 = 1.

SET PROPERTY OF sheet 'Name' = 'Third'.

CALL METHOD OF sheet 'Activate'.

LOOP AT itab3.

index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name

CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.

*SET PROPERTY OF cells 'Formula' = itab3-formula.

SET PROPERTY OF cells 'Value' = itab3-third_name.

ENDLOOP.

*Create fourth Excel sheet

CALL METHOD OF application 'Sheets' = sheet.

CALL METHOD OF sheet 'Add'.

CALL METHOD OF application 'Worksheets' = sheet

EXPORTING #1 = 1.

SET PROPERTY OF sheet 'Name' = 'Fourth'.

CALL METHOD OF sheet 'Activate'.

LOOP AT itab4.

index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name

CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.

SET PROPERTY OF cells 'Value' = itab4-fourth_name.

ENDLOOP.

*fifth

CALL METHOD OF application 'Sheets' = sheet.

CALL METHOD OF sheet 'Add'.

CALL METHOD OF application 'Worksheets' = sheet

EXPORTING #1 = 1.

SET PROPERTY OF sheet 'Name' = 'Fifth'.

CALL METHOD OF sheet 'Activate'.

LOOP AT itab4.

index = row_max * ( sy-tabix - 1 ) + 1. " 1 - column name

CALL METHOD OF sheet 'Cells' = cells EXPORTING #1 = index.

SET PROPERTY OF cells 'Value' = itab4-fourth_name.

ENDLOOP.

*Save excel speadsheet to particular filename

CALL METHOD OF sheet 'SaveAs'

EXPORTING #1 = 'C:\Documents and Settings\rony.leon\Desktop\test\exceldoc1.xls' "filename

#2 = 1. "fileFormat

*Closes excel window, data is lost if not saved

SET PROPERTY OF application 'visible' = 1.