How can I get an ABAP program displaying Excel data to wrap text?

Learn how to display details from a Microsoft Excel database table using the Wrap Text function when developing an SAP ABAP program.

I am developing an SAP ABAP program (using an SAP R/3 4.7 system), in which I want to display details from a database table in Mircrosoft Excel.

Looking at the various demo programs that SAP has provided, I found one that seems to meet my needs. This program (saprdemo_tables_in_excel) allows you to load data from internal tables into a worksheet (shown in-place in the program's screen) and also allows the program to extract the data from the worksheet so that the internal tables can be updated. This program makes use of Desktop Office Integration and is quite easy to follow and understand.

I've created my own program based on the SAP program and have been able to develop it so that it meets my needs. However, there is one requirement (probably the main requirement) that I've found I can't satisfy.

I need some of the cells to have the "Wrap Text" option enabled but cannot see how to do that. None of the methods from the I_OI_SPREADSHEET interface allow me to change this. There are methods that allow me to change the font size and color and background color, as well as properties such as Bold, Italic and Justified, but nothing that relates to the Wrap Text option.

I've been able to find information that seems to indicate that the Wrap Text property can be set if the program was written around OLE2 objects such as with the following code:

 

CREATE OBJECT o_wks 'Excel.Application' NO FLUSH. GET PROPERTY OF o_wks 'Range' = o_rng1 NO FLUSH exporting #1 = 'D:D'. SET PROPERTY OF o_rng1 'WrapText' = '1'.

However, since I am using the I_OI_SPREADSHEET interface, I'm struggling to see how I can make use of this approach. Is there some way that I can set the Wrap Text property of a cell in my program given that it is based around the saprdemo_tables_in_excel program?

Rather than create a new Excel workbook directly, have this read in a template workbook, with an embedded macro to set the Wrap Text property. Add your data to this template and run the macro. Then use Save As to make your new document. I've often used this technique for problematic OLE programming -- it's a lot easier to write a macro.

Dig Deeper on SAP development and programming languages

ERP
SearchOracle
Data Management
SearchAWS
Business Analytics
Content Management
HRSoftware
Close