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: 

ws_excel, ending .xls instead of .txt

Former Member
0 Kudos

Hello,

I am using function module ws_excel in order to show an excel file which is working well. When saving this excel sheets EXCEL always suggests the ending .txt and the user has to change manually to .xls.

Who can I change this suggestion to .xls?

regards

stefan

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Stefan,

WS_EXCEL basically calls WS_DOWNLOAD to download the internal table as a file then calls the Excel application to open the data( using WS_EXECUTE). Normally the file is going to be of type DAT and its a Tab delimited file. As s result Excel application will try to save it as tab delimited file - resulting selection of .TXT extension of the same.

You can

- manually do a Save As on the Excel - something that u r already doing.

- or you can go for FM - ALV_XXL_CALL.

- Use OLE methods to take care of it.

6 REPLIES 6

Former Member
0 Kudos

Hi

It's better to handle programatically.

In the file name itself add .XLS to your file name.

call function 'WS_EXCEL'

exporting

filename = 'TEST.XLS'

tables

data = imara.

If your requirement demands user to give file name, take it as parameter then concatenate .XLS to the parameter. Then use that parameter for FileName in the above call.

Regards

Surya.

0 Kudos

Hi Surya,

thats the way I am doing it. But when the user changes the excel sheets and wants to save it with 'SAVE UNDER' system still suggests .txt.

regards

stefan

0 Kudos

hi

then you use fm gui_download.

that time u will get .txt file.

regards

kumar.

Former Member
0 Kudos

hi,

please paste the below code so ur problem will be soled. i tested tbelow sample program while executing the report it is displaying the outptu in excel sheet only.

plese see below code and change the code in your program.

tables: mara.

data: begin of it_mara occurs 0,

matnr type mara-matnr,

ersda type mara-ersda,

end of it_mara.

parameters: p_matnr type mara-matnr.

select matnr

ersda

from mara

into table it_mara

where matnr = p_matnr.

CALL FUNCTION 'WS_EXCEL'

EXPORTING

FILENAME = 'c:\tmp\test.xls'

  • SYNCHRON = ' '

TABLES

DATA = it_mara

.

thanks,

maheedhar

Former Member
0 Kudos

Hi Stefan,

WS_EXCEL basically calls WS_DOWNLOAD to download the internal table as a file then calls the Excel application to open the data( using WS_EXECUTE). Normally the file is going to be of type DAT and its a Tab delimited file. As s result Excel application will try to save it as tab delimited file - resulting selection of .TXT extension of the same.

You can

- manually do a Save As on the Excel - something that u r already doing.

- or you can go for FM - ALV_XXL_CALL.

- Use OLE methods to take care of it.

Former Member
0 Kudos

Hello SKC,

thanks for the explanation.

regards

stefan