‎2008 Jun 20 1:12 PM
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.
‎2008 Jun 20 1:14 PM
‎2008 Jun 20 1:14 PM
‎2008 Jun 23 8:16 AM
Hi all,
is there any way to download data to excel in background.
pls help reg this.
‎2008 Jun 26 11:52 AM
‎2008 Jun 26 11:56 AM
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.....
‎2008 Jun 27 7:03 AM
&----
*& 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.