Registration

Dear SAP Community Member,
In order to fully benefit from what the SAP Community has to offer, please register at:
http://scn.sap.com
Thank you,
The SAP Community team.
Skip to end of metadata
Go to start of metadata

Output:-
 

Code:-

Error rendering macro 'code': Invalid value specified for parameter 'lang'
REPORT ZOLE_DEMO.
TYPE-POOLS OLE2.
DATA: EXCEL TYPE OLE2_OBJECT,
WORKBOOKS TYPE OLE2_OBJECT,
WORKBOOK TYPE OLE2_OBJECT.
DATA: FILENAME LIKE RLGRAP-FILENAME.
*Create object of excel
CREATE OBJECT EXCEL 'excel.application'.
PERFORM ERR_HAND.
*Set property visible = 1 else excel will not be shown
SET PROPERTY OF EXCEL 'VISIBLE' = 1.
PERFORM ERR_HAND.
*Display progress indicator in current window
CALL FUNCTION 'SAPGUI_PROGRESS_INDICATOR'
  EXPORTING
    PERCENTAGE = 0
    TEXT       = 'This process indicates '.
*method to display workbook
CALL METHOD OF EXCEL 'WORKBOOKS' = WORKBOOKS.
PERFORM ERR_HAND.
*method to add sheets in workbook
CALL METHOD OF WORKBOOKS 'ADD' = WORKBOOK.
PERFORM ERR_HAND.
*name of the excel.
CONCATENATE SY-REPID '' SY-DATUM+6(2) '' SY-DATUM+4(2) '_'
SY-DATUM(4) '_' SY-UZEIT '.XLS' INTO FILENAME.
*set the name of the workbook in the save as dialog box
.CALL METHOD OF WORKBOOK 'SAVEAS' EXPORTING #1 = FILENAME.
*&---------------------------------------------------------------------*
*& Form err_hand
*&---------------------------------------------------------------------*
* text
*----------------------------------------------------------------------*
FORM ERR_HAND.
*return message in case of error.
  IF SY-SUBRC <> 0.
    WRITE: / 'OLE ERROR: RETURN CODE ='(I10), SY-SUBRC.
    STOP.
  ENDIF.
ENDFORM. "err_hand