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: 

downlaod to Excel sheet using ole

Former Member
0 Kudos

hi,

I am using ole2 method for downloading data into Excel.In the excel all the character fields are left aligned and all the numeric fields are right aligned .

I want all my data to be left aligned ,pls let me know how it can be done thru the program.

Thnx

Bhanu.

1 ACCEPTED SOLUTION

former_member189059
Active Contributor
0 Kudos

Hello Bhanu,

There are a couple of little tricks to get everything to appear left aligned

1. There is an object 'HorizontalAlignment' which needs to be set to 'xlLeft' to force excel to display numbers left aligned - though i have never used it, so i cannot guide you more on this

2. If you simply append an apostrophe to your field before passing it to excel, the data will appear left aligned and the apostrophe will not show in the excel sheet (it will only show in the formula bar)

to append the apostrophe, first ensure that your field is one character longer than it was earlier (to fit in the apostrophe)

then use this code

concatenate '''' fieldname into fieldname.

the '''' is the escape sequence for apostrophe

4 REPLIES 4

Former Member
0 Kudos

in that case u have to define/declare ur Internal Table like that.

data: begin of itab occurs 0,

data(10) type c,

name(10) type c,

end of itab.

Regards

Peram

Former Member
0 Kudos

In Excel sheet , you will always see numeric fields right-aligned..

If ur file is tab separated, open it in notepad, then u'll see all fields are left aligned.. but if u open it in Excel then all numeric fields will be right aligned.

You have to make changes in sheet itself.. not in ABAP code.

You can't do that in the code.

Reward if useful

Regards

Prax

former_member189059
Active Contributor
0 Kudos

Hello Bhanu,

There are a couple of little tricks to get everything to appear left aligned

1. There is an object 'HorizontalAlignment' which needs to be set to 'xlLeft' to force excel to display numbers left aligned - though i have never used it, so i cannot guide you more on this

2. If you simply append an apostrophe to your field before passing it to excel, the data will appear left aligned and the apostrophe will not show in the excel sheet (it will only show in the formula bar)

to append the apostrophe, first ensure that your field is one character longer than it was earlier (to fit in the apostrophe)

then use this code

concatenate '''' fieldname into fieldname.

the '''' is the escape sequence for apostrophe

0 Kudos

Hi Kris,

Thanks a ton!

I am stuck with another problem .

Plesase look into the new thread of mine.

Hope u answer this also.

regards,

Bhanu.