11-21-2014 2:55 PM
Hi Experts
I am using the following code to save the internal table as excel file on presentation server: -
CALL METHOD cl_gui_frontend_services=>file_save_dialog
EXPORTING
window_title = 'Choose a location'
CHANGING
filename = fname
path = fpath
fullpath = fpath_full
EXCEPTIONS
cntl_error = 1
error_no_gui = 2
not_supported_by_gui = 3
OTHERS = 4.
IF sy-subrc <> 0.
ENDIF.
DATA: lv_title TYPE text,
lv_returncode TYPE c,
lt_fields TYPE TABLE OF sval.
lv_filename = fpath_full.
CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
EXPORTING
i_field_seperator = lv_char
i_filename = lv_filename
TABLES
i_tab_sap_data = lt_tscript
EXCEPTIONS
conversion_failed = 1
OTHERS = 2.
IF sy-subrc <> 0.
* Implement suitable error handling here
ENDIF.
It works fine for me in excel 2010 but in excel 2013 (Windows 8), i am getting the error "file format not valid".
I tried with OLE method as well, no luck on that one too!
Any pointers on this issue would be highly appreciated.
Thanks
Best Regards
Shreya
11-21-2014 3:09 PM
When are you getting this error ? When you call the function module 'SAP_CONVERT_TO_XLS_FORMAT' or when you donwload the file (code snippet missing) or when you try to open the downloaded file ?
Maybe use SAP_CONVERT_TO_XML_FORMAT because Excel 2013 can open xml files without any problem.
11-24-2014 7:01 PM
Hi Peter
Thanks for replying.
I get the 'file format invalid' error while opening the downloaded excel file.
As per your suggestion, I tried with converting to XML format. It is also giving error while opening the file - 'XML parser error'.
Thanks
Regards
Shreya
11-24-2014 7:38 PM
Hi Shreya,
try using
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
EXPORTING
WINDOW_TITLE = ''
DEFAULT_EXTENSION = 'xlsx'
FILE_FILTER = '*.xls'
CHANGING
FILENAME = lv_filename
PATH = lv_path
FULLPATH = 'Pathname'.
call the SAP_CONVERT_TO_XLS_FORMAT again.
Hope it helps.
Regards,
Kannan
11-25-2014 7:14 AM
Hello Shreya,
Try with the below option.
1) CALL METHOD cl_gui_frontend_services=>file_open_dialog
2) CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_SAVE_DIALOG
3) CALL FUNCTION 'SAP_CONVERT_TO_XLS_FORMAT'
or
1) CALL METHOD cl_gui_frontend_services=>file_open_dialog
2) CALL METHOD CL_GUI_FRONTEND_SERVICES => GUI_DOWNLOAD
When the first step is executed, Displays a File Open Dialog and the system will ask you for a reference file in the presentation server.
Create a empty file with extension .xlsx and then refer the file.
Regards,
Thanga
12-03-2014 5:01 AM
12-03-2014 6:36 AM
Hello Shreya,
You will also need the latest version and patch level of SAPGUI.