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: 

OLE - XL Sheet not opening

P507709
Participant
0 Kudos

Hi All,

Iam extracting data from al11 and putting that data into xls using ole. Now when i try to open that file it is not opening.

i dont want to display xls directly but i want to save it to a local drive and open it later .

For this purpose i had written a code as

create object w_excel 'EXCEL.APPLICATION'.

set property of w_excel 'VISIBLE' = 0.

visible set to 0 because i dont want to open data in xls after just executing my report.

call method of w_workbook 'SAVEAS'

exporting #1 = p_file.

To download the file in specified location.

When i try to open after downloading its not getting opened. One more thing is if i open any other XL Sheet in my local machine then this ole XL Sheet is getting opened.

Thanks

Durgaprasad

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi Durga,

Since you do not want to open the excel file directly I would suggest using:

class CL_GUI_FRONTEND_SERVICES

or the function

GUI_DOWNLOAD

to download the data.

Kind regards,

Robert

7 REPLIES 7

Former Member
0 Kudos

Hi Durga,

Since you do not want to open the excel file directly I would suggest using:

class CL_GUI_FRONTEND_SERVICES

or the function

GUI_DOWNLOAD

to download the data.

Kind regards,

Robert

0 Kudos

Hi robert,

Thanks for your reply and as u said am using call method cl_gui_frontend_services=>clipboard_export to save the file.

Its getting saved sucessfully but when i try to open it, it does not opens .

If i open any other xls file from my desktop then only the required given file opens .

Pls suggest me.

Thanks,

Durga

0 Kudos

Hi Durga,

The class CL_GUI_FRONTEND_SERVICES has a lot useful methods which can be used for desktop function. Please read maybe the documentation provided with this class (SE24).

With the code below, you can save a file with extension .XLS to the user's desktop and it will open automatcially.

 
  cl_gui_frontend_services=>gui_download(
    exporting
      filename                  = lf_fileloc
      write_field_separator     = cl_abap_char_utilities=>horizontal_tab
    importing
      filelength                = lf_filelength
    changing
      data_tab                  = mt_export
    exceptions
      file_write_error          = 1
      no_batch                  = 2
      gui_refuse_filetransfer   = 3
      invalid_type              = 4
      no_authority              = 5
      unknown_error             = 6
      header_not_allowed        = 7
      separator_not_allowed     = 8
      filesize_not_allowed      = 9
      header_too_long           = 10
      dp_error_create           = 11
      dp_error_send             = 12
      dp_error_write            = 13
      unknown_dp_error          = 14
      access_denied             = 15
      dp_out_of_memory          = 16
      disk_full                 = 17
      dp_timeout                = 18
      file_not_found            = 19
      dataprovider_exception    = 20
      control_flush_error       = 21
      not_supported_by_gui      = 22
      error_no_gui              = 23
      others                    = 24 ).

  if sy-subrc eq 0.

    call method cl_gui_frontend_services=>execute
      exporting
        document               = lf_fileloc
      exceptions
        cntl_error             = 1
        error_no_gui           = 2
        bad_parameter          = 3
        file_not_found         = 4
        path_not_found         = 5
        file_extension_unknown = 6
        error_execute_failed   = 7
        synchronous_failed     = 8
        not_supported_by_gui   = 9
        others                 = 10.

endif.

Kind regards,

Robert

0 Kudos

Hi Durga Prasad,

with [Desktop Office Integration (BC-CI)|http://help.sap.com/printdocu/core/Print46c/en/data/pdf/BCCIOFFI/BCCIOFFI.pdf] you do not need any GUI frontend method. You can open, fill and save the excel on the client (your PC).

Regards,

Clemens

0 Kudos

Correct.

The only reason I suggested the front-end services was to propose to Durga the more common used techniques for downloading an excel file as I did not get the impression from his question that OLE was a requirement.

Kind regards,

Robert

0 Kudos

Hi Robert,

Durga wrote

create object w_excel 'EXCEL.APPLICATION'.
set property of w_excel 'VISIBLE' = 0.

I thought: OK, OLE without the SAP DOI - no wonder that does not work.

Regards,

Clemens

Former Member
0 Kudos

Do you these in your code after you save.....

CALL METHOD OF EXCEL 'QUIT'.

and

Free object cell, excel, workbook.