全部博文(90)
分类:
2009-04-03 11:13:50
*Download to Excel using OLE
IF px_ole EQ 'X'.
PERFORM ole_excel.
ENDIF.
ENDIF.
*&---------------------------------------------------------------------*
*& Form ole_excel
*&---------------------------------------------------------------------*
* Using OLE write to Excel
*----------------------------------------------------------------------*
FORM ole_excel.
*--> start excel
CREATE OBJECT wf_excel 'EXCEL.APPLICATION'.
SET PROPERTY OF wf_excel 'Visible' = 1.
*--> get list of workbooks, initially empty
CALL METHOD OF wf_excel 'Workbooks' = wf_mapl.
*--> Add a new workbook
CALL METHOD OF wf_mapl 'Add' = wf_map.
*-->Fill Column Headings of Excel
PERFORM fill_cell USING:
1 1 1 '10.36' 'Practice Area',
1 2 1 '6.36' 'Service ID',
1 3 1 '15.36' 'Service Description',
1 4 1 '6.36' 'Service Type',
1 5 1 '10.36' 'Degree of Control',
1 6 1 '8.36' 'Service Price',
1 7 1 '10.36' 'Revenue Cost Element',
1 8 1 '10.36' 'Expense Cost Element',
1 9 1 '8.36' 'Billable Unit',
1 10 1 '10.36' 'Service Start Date',
1 11 1 '10.36' 'Service End Date',
1 12 1 '15.36' 'Product Manager Name',
1 13 1 '7.36' 'Product Manager ID',
1 14 1 '15.36' 'Product Manager Email',
1 15 1 '10.36' 'Product Manager Telephone',
1 16 1 '42.36' 'Client Roles and Responsibilities',
1 17 1 '42.36' 'Features'.
****Rest of the code is removed in this code snippet******
*---------------------------------------------------------------------*
* FORM FILL_CELL *
*---------------------------------------------------------------------*
* sets cell at coordinates i,j to value val boldtype bold *
*---------------------------------------------------------------------*
FORM fill_cell
USING
i " X - Co-ordinate
j " Y - Co-ordinate
bold " Font Bold
width " Width of Column
val. " Value of Cell
*---->Create the Cell at the Co-ordinate and Take the Reference
CALL METHOD OF wf_excel 'Cells' = wf_zl
EXPORTING
#1 = i
#2 = j.
*---> Set the Value
SET PROPERTY OF wf_zl 'Value' = val .
*---> Get the Reference of Font for the value filled
GET PROPERTY OF wf_zl 'Font' = wf_f.
*--->Set the Font as bold
SET PROPERTY OF wf_f 'Bold' = bold .
*--->Borders around the cell
CALL METHOD OF wf_zl 'BorderAround'
EXPORTING
#1 = 1
#2 = 2.
*--->Create the Range of Cells
CALL METHOD OF wf_excel 'Range' = wf_range
EXPORTING
#1 = wf_zl
#2 = wf_zl.
*--->Set the Columns width
SET PROPERTY OF wf_range 'ColumnWidth' = width.
ENDFORM. "FILL_CELL