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

EXport Data to Excel with Columns format

venkateswaran_k
Active Contributor
0 Likes
1,265

Dear All,

This may be a basic question, however, I just need a tip to conclude my issue.

I have a Report that displays Financial Budget data (AFE). I am able to download to the Excel sheet. However, I need to conclude it with the column formatted at code itself and not given to the user.

That is I want to set couple of column to Numeric, and Set Colum width defined at Code level itself.

I am already using the Function module : MS_EXCEL_OLE_STANDARD_DAT

Regards,

Venkat

Dear All,

This may be a basic question, however, I just need a tip to conclude my issue.

I have a Report that displays Financial Budget data (AFE). I am able to download to the Excel sheet. However, I need to conclude it with the column formatted at code itself and not given to the user.

That is I want to set couple of column to Numeric, and Set Colum width defined at Code level itself.

I am already using the Function module : MS_EXCEL_OLE_STANDARD_DAT

Regards,

Venkat

2 REPLIES 2
Read only

Former Member
0 Likes
770

data: go_excel type ole2_object,

Go_CELL TYPE OLE2_OBJECT,

go_workbooks TYPE OLE2_OBJECT,

go_workbook TYPE OLE2_OBJECT,

go_sheet type OLE2_OBJECT,

go_application type OLE2_OBJECT,

go_activesheet type OLE2_OBJECT,

go_text type OLE2_OBJECT.

gv_EXTRD = sy-datum.

gv_EXTRT = sy-uzeit.

concatenate pfile gv_EXTRD gv_EXTRT 'check.xls' into gv_file.

clear: gt_export, gs_export.

****INITIATE EXCEL

  • Create object Excel

create object go_excel 'EXCEL.APPLICATION'.

set property of go_excel 'Visible' = 0.

  • Create workbook object

call method of go_excel 'WORKBOOKS' = go_workbook .

  • Add workbook

call method of go_workbook 'Add' = go_workbook.

lv_line = 0.

loop at gt_collect ASSIGNING <collect>.

lv_line = lv_line + 1.

move-corresponding <collect> to gs_export.

clear: gs_export-ZALDT.

concatenate <collect>-ZALDT4(2) '-' <collect>-ZALDT6(2) '-' <collect>-ZALDT+0(4)

into gs_export-ZALDT.

  • Populate cells

call method of go_excel 'Cells' = Go_CELL

EXPORTING

#1 = lv_line

#2 = 1.

**************SET UP PROPERTY WIDTH ****************************

SET PROPERTY OF GO_CELL 'ColumnWidth' = '11'.

SET PROPERTY OF GO_CELL 'Value' = gs_export-BANKL.

***********SET PROPERTY CELL NUMBER**************************************

call method of go_excel 'Cells' = Go_CELL

EXPORTING

#1 = lv_line

#2 = 4.

SET PROPERTY OF go_cell 'NumberFormat' = '@'. "PROPERTY NUMBER

SET PROPERTY OF GO_CELL 'ColumnWidth' = '10'.

SET PROPERTY OF GO_CELL 'Value' = gs_export-ZALDT.

endloop.

**CLOSE EXCEL**********

CALL METHOD OF go_workbook 'SaveAs'

EXPORTING #1 = gv_file

#2 = 1.

"file format

CALL METHOD OF go_workbook 'close'. "file format

call method of go_excel 'QUIT'.

****OPEN CREATED EXCEL FILE ****************************

call method of go_excel 'Workbooks' = go_workbooks.

call method of go_workbooks 'Open'

EXPORTING

#1 = gv_file.

set property of go_excel 'Visible' = 1.

Read only

venkateswaran_k
Active Contributor
0 Likes
770

Thanks a lot. Helpful note.