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: 

Download to excel not working for Excel 2013

Former Member
0 Kudos

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

6 REPLIES 6

PeterJonker
Active Contributor
0 Kudos

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.

0 Kudos

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

Former Member
0 Kudos

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

thanga_prakash
Active Contributor
0 Kudos

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


thanga_prakash
Active Contributor
0 Kudos

Hello Shreya,

Is your problem solved?

Regards,

Tp

yuki_wang
Active Participant
0 Kudos

Hello Shreya,

You will also need the latest version and patch level of SAPGUI.