Application Development 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: 

OLE Automation to Excel Applications

Former Member
0 Kudos

Hii Friends,

I am working on an OLE automation object, where my report program should call an Excel file using OLE connection.

Here I am able to print all the data in Excel, from SAP. However I am facing a problem in writting -ve values.

i.e

if value of a variable, say temp = -5 in ABAP, is should display (5) in Excel.

This is the requirement.

what I am doing is

concatenate '(' temp ')' into str_temp .

And passing it to Excel, bt in Excel it still shows -5.

Can somebody pls help me, how to fix this ?

Is thr any property to fix this?

Regards,

Hardik

8 REPLIES 8

Former Member
0 Kudos

Is my question clear? or I need toexplain in more dateil?

0 Kudos

Its very urgent.

Somebody PLS HELP................

hardik

former_member194669
Active Contributor
0 Kudos

Hi,

Try with replace

REPLACE '-' WITH space INTO temp.

concatenate '(' temp ')' into str_temp .

aRs

0 Kudos

Hi

In Debugging mode, I can see my deta moves to Excel in correct format.

I mean, str_temp = (5). But if u open a blank Excel file and type (5) and press Enter. It will internally convert it to -5... that is what happening in my case.

In Excel if you go to, Format->Cells->Numbers, you can disable this option..

So is there a way or property or method in ABAP "Excel Object", I can do the same without manually doing it in Excel.

Hardik

Former Member
0 Kudos

Hi hardik,

why don't you change it in positive?

if temp < 0. tmep = temp * ( -1 ). endif.

Regards, Dieter

Former Member
0 Kudos

Hi Hardik,

try this:

Range as you need.

CALL METHOD OF H_EXCEL 'RANGE' = H_RANGE EXPORTING #1 = 'U1:U2'.

SET PROPERTY OF H_RANGE 'NumberFormat' = "#,##0.00". "You own format

Regards, Dieter

Former Member
0 Kudos

Hi,

Did you try to add a single quote in front of the value, e.g. '(5)?

Excel will consider this as an alpha value and not format it (it will be left justified though).

Thanks,

Guenther

former_member194669
Active Contributor
0 Kudos

Hi,

Otherwise try to use

CALL METHOD OF CELL 'SET_FORMAT' = TEXT.

SET PROPERTY OF TEXT 'CATEGORY' = 4.

aRs