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.
Methods including;
| ADD_HEADER_VIA_FCAT | Add header via fCat |
| ADD_LINE | Add line via structure |
| ADD_LINE_VIA_TAB | Add line via table |
| ADD_LINES_VIA_TAB | Add lines via table |
| SET_FORMAT | Set format |
| SET_BORDER | Set border |
| SET_ALIGNMENT | Set alignment |
| SET_AUTOFILL | Set autofill |
| SET_AUTOFIT | Set autofit |
| SET_COL_WIDTH | Set column width |
| SET_ROW_HEIGHT | Set row height |
| SET_PAGESETUP | Set page setup |
| SET_IMAGE | Set image |
| SET_VALUE | Set value |
| GET_VALUE | Get value |
| GET_ROW_COUNT | Get row count of clipboard table |
| GET_APP_OBJECT | Get application object for custom dev |
| CLIPBOARD_EXPORT | Clipboard export |
| SAVE_DOCUMENT | Save document |
| CLEAR_CLIPBOARD | Clear clipboard data |
| FREE | Destructor |
| Print Document |
You can just copy and paste the code in “Source Code-Based” class builder editor of a global usual ABAP Class.
(Fork me on GitHub if you want to contribute)
P.S. For suggestions or reviews pls. contact.
Good job
Very helpful!