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: 

Display leading zeros in OLE

Former Member
0 Kudos

Hi Friends,

When I am writing report in OLE( excel ), some of the fields which are having leading zeros automatically deleted . It shoud not happen . I have to display leading zeros also.

Please tell me which class and method to do this ...

Thanks ,

Varma

5 REPLIES 5

Former Member
0 Kudos

Hi,

Try adding the character ' (single quote) before the actual value. Excel then treats the value as-is whithout conversion.

Hope this helps (please reward me if it does).

Regards, Joerg

0 Kudos

Joerg

You are right ...But it will display as some warning message . Client don't want that ...I tried with Different classes and methods also. Might be the way I am writing code could be wrong . If I get class and method how to write code for that can you help me in this ??

Thanks in adv

Varma

0 Kudos

Hi Varma,

What kind of warnigs do you get?

Also, there might be another way. Use the clipboard to transfer the data from SAP to EXCEL. This works quite well. Use the class method cl_gui_frontend_services=>clipboard_export and provide the data as an internal table of string separated by tab characters.

Or you can use GUI_DOWNLOAD to create a CSV file and open it in EXCEL...

Regards, Joerg

former_member189059
Active Contributor
0 Kudos

Use OLE itself to set the formatting of the cell (or column itself) to character type

* character type for columns
data: h_columns        TYPE ole2_object,
      h_cell           TYPE ole2_object.
CALL METHOD OF excel 'Columns' = h_columns
  EXPORTING
    #1 = 'F:K'.

set property of h_columns 'NumberFormat' = '@'.

CALL METHOD OF excel 'Cells' = h_cell
  EXPORTING
    #1 = 14
    #2 = 7.
SET PROPERTY OF h_cell 'Value' = '0001'.

former_member189059
Active Contributor
0 Kudos

In the above case, I have set the formatting of columns F to K as Text type

To do the same thing in excel itself, Right click on the Column -> format cells -> click on Text, then click on OK