Application Development Blog Posts
Learn and share on deeper, cross technology development topics such as integration and connectivity, automation, cloud extensibility, developing at scale, and security.
cancel
Showing results for 
Search instead for 
Did you mean: 
zaferonbas
Participant


OLE2Object - ABAP OLE2 Object Utility Class


As we all know, sometimes comprehensive dynamic Excel automation developments can be a little bit complicated with OLE2_OBJECT methods. You have to record a macro and find out what's going on in VBA (Visual Basic for Applications) codes for each specific process, if you don't know it backwards .)

Hence, about a year ago I wrote a simple utility class for mostly needed common processes (e.g. set/get values, formatting options etc.) in Excel automation. You can simply create a new Excel sheet or open an existing one and manipulate it as you want.

You can just copy and paste the code in "Source Code-Based" class builder editor of a global usual ABAP Class.

Source code on GitHub:
https://goo.gl/axI0qO
(Fork me on GitHub if you want to contribute)

Originally published at – ABAP OLE2 Object Utility Class
8 Comments
Former Member
0 Kudos
Hi Zafer,

Thanks for the wonderful blog.

I have copied the code and tested. It is working fine and generating an excel file in ".XLS" format. So my question is: Can we create an excel file with ".XLSX" format uisng OLE2? if so please guide me to achieve that.

Thanks,

Shashi

 

 
hardyp180
Active Contributor
0 Kudos
I would suggest doing as Google search on ABAP2XLSX.

Every few months someone comes up with a new way to export SAP data to Excel, but in my opinion ABAP2XLSX takes some beating.

 
zaferonbas
Participant
0 Kudos
Hi Shashi,

I'm glad you like it. Sure we can create it with "XLSX" format. Actually it's a better practise .) so I've just committed the change in GitHub for Excel create and open modes.

Thanks,
Zafer
zaferonbas
Participant
Hi Paul,

I knew "ABAP2XLSX" before I wrote my own class. I think, it's a perfect tool for advanced level apps, but so detailed for basic and ITM Excel manipulations.You should use STMS or SAPLink to install dozens of Classes, DDIC Objects etc. to your system even though you don't need them. It's more trouble than it's worth if you just develop an app that I mentioned above.

Thanks,
Zafer
former_member620315
Discoverer
hi,

Congrats for the blog. It is very helpful.

I have used the "ole2_object " to create and format an excel file. The program is 100% functional when I access it via SAPLogon. However when the business users access it through Fiori it doesn't work.

The problem is probable caused because the excel file is exported locally (path: C:/....) in my PC through SAPLogon via the use of the excel application which is available,

" CREATE OBJECT application 'Excel.Application'."

whereas the excel is exported in SAP (path: z:/...) through Fiori. In sap server there is no excel application installed.

Is there any solution for this issue?

Thanks and regards,

Maria L.

 

 
zaferonbas
Participant
Hi Maria,

AFAIK, OLE2 Automation object requires a front-end session to get its work done. Because Fiori/WebGUI apps are stateless (working externally), you can't use OLE2 Automation from web browser (in case of Creation/Upload etc.). Instead you can use xml based ABAP2XLSX for your case.

Thanks,
Zafer

 
former_member620315
Discoverer
The ABAP2XLSX works. Thanks!
hamida_ashna
Explorer
0 Kudos
Hi,

Thanks for the blog. It is very helpful.

I have question. How we can identify and get position of a specific table through the table name from an Excel file?  Which one is better to use, ABAP2XLSX or OLE2 ?


 

Thanks and regards,

Hamida
Labels in this area