Application Development and Automation 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: 
Read only

Format Excel cell

Former Member
0 Likes
1,661

Hi,

I am writing a program that will send out an email with an excel attachment. When I open the excel file, it does show the leading zeros if the value contents only digits. For example. if the plant is '0005' the file displays just '5'. Do you know how to format the cell to text field?

I am using FM 'SO_DOCUMENT_SEND_API1' for the email sending.

Thanks,

Chuong

11 REPLIES 11
Read only

Former Member
0 Likes
1,126

my typo -- does not show the leading zeros.

Read only

Former Member
0 Likes
1,126

It's an excel thing.

The easiest solution is just to place a non numeric character at the beggining or end of the number to treat it like a string.

Something like .005 or {005

Read only

0 Likes
1,126

I'm thinking of a single quote but don't know how to define single quote in ABAP. Please help!

Read only

0 Likes
1,126
DATA LV_SINGLE TYPE CHAR01 VALUE '''' .
Read only

0 Likes
1,126

Thanks. However, the single quote does not have the same functionality as in Excel. It does not change to the text format.

Read only

0 Likes
1,126

I think if you pass data as '0005 then it should display as 0005 in excel.

Could you check whether you are loosing leading zero before you are passing the data to FM (for email)

If you are using CONCATENATE statement to add single quote to plant then check whether you are loosing zeros there.

Read only

0 Likes
1,126

I still have the zeors before passing to the FM. In excel, it displayed '0005 instead of 0005.

Read only

0 Likes
1,126

Hi,

You can configure the Excel to display the cell/collum in text format.

Best regards.

Henrique

Read only

0 Likes
1,126

Hi Henrique,

Can we do this in SAP instead of Excel? Thanks!

Read only

0 Likes
1,126

Hi,

If you are using OLE automation to create the excel, you should format the cell like this:

 
SET PROPERTY OF cell 'NumberFormat' = '@'.

Regards,

Claudiu

Read only

naimesh_patel
Active Contributor
0 Likes
1,126

Your file contains the leading zeros but when you open it in Excel, Excel is removing those leading zeros. Because excel treats that as a number.

Check this on [Preserve Downloaded data formatting in Excel |http://help-abap.blogspot.com/2008/09/preserve-downloaded-data-formatting-in.html]

Regards,

Naimesh Patel