Update: Even though I mentioned it in the end of this post, as well as on the TXT file with the original ABAP code, it is worth mentioning again that this is an original article written by Alvaro Tejada (@blag). For more information, click here to access Alvario Tejada’s blog. Also, please refer to a recent post that I’ve written called “10 SAP Blogs you must follow“, which also mentions @Blag’s blog as one of my 10 SAP favorite blogs.
If you’re an ABAP programmer, chances are that one of these days your team leader asks to you build a Report to export ERP data into an Excel sheet. The idea behind this ABAP report is simple. The user runs the report from the ERP system and is able to save it locally as an Excel worksheet, probably to send it to a Line Manager or someone from business who wants to look at figures. Of course this is just an example but it will give you the basic tools on how to work with ABAP and Excel OLE. It also gives you some pointers on how to manipulate cell colors. So, here are the steps to enable this simple example.
1. Create the Report, transaction code SE38

2. In the example, I named the report ZHCM_ABAP_TO_EXCEL. Click on Create
3. Next you should type in some normal report creation parameters

4. Hit Save, choose your development package and you’re ready to start editing your report source code
5. Copy and paste the source code available for download here
6. Hit Activate and click on F8 or the Direct Processing button

7. Upon executing the report, you will need to define the name and location of the result Excel file. On the example defined in a folder \test-excel\test-excel.xls. Hit Save

8. Back on the selection screen, confirm your entries and execute the Report

9. The result will be something like

Additional links and resources








Hien Ngo Minh
this is a very good tutorial, it helps me a lot. Thx admin
Hong Son
Thank You very much, I am new to ERP,these materials are very useful for me.
crepmaster
how can download the excel into a application server?
Tony
Try to use abap2xlsx SCN Community Project
http://www.sdn.sap.com/irj/scn/weblogs?blog=/pub/wlg/20046
Regards
webmaster
Dear Tony,
Thank you for your contribution.
Regards.
Antonio Caldas
Jenith Kumar
I need to set the format of the cell as TEXT, which can be found in the Number Tab of the Format Cells Window.
How to Get these properties in the program?
Regards,
Jenith Kumar.
Long
How to export data from SAP system to excel version 2007 or newer versions?
Thanks anh regards!
Long.
Long
And how to insert company logo when export to excel file from SAP?
Thanks alot!
Long.
Adrian Buendia
Thank you very much for the very very good sample.
More power to you.