01-13-2012 10:51 AM
Hi All,
I am downloading a data from SAP to excel(*.xlsx) format. I am able to conver/download the file in *.xlsx format, but if try to open the downloaded excel file, it gives teh error message 'Excel cannot open the file 'filename.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file'. with a OK button. When I press the OK button, no data is displayed.
So kindly let me know how to download the file from SAP to *.xlsx format without any errors.
Note: I am able to download the data in *.xls format without any erros.
Thanks in advance,
Regards,
Vijay
01-13-2012 11:22 AM
Hi,
Please go to transaction DC30 and check what extension is maintained in the suffix field for excel file. You can only download to the suffix which is maintaied. This is SAP behaviour, not because of your coding.
Regards,
Manish Sethia
01-13-2012 11:40 AM
Hi,
You are probably not being able to open the file of .XLSX format because you do not have Microsoft Office 2007 installed on your system. You might be having a lower version of Microsoft Office. e.g. 2003.
What you can do is, before opening the .XLSX file directly on a system which does not have Microsoft Office 2007, you can convert it into .XLS format and then open the same.
See the below code.
CALL METHOD CL_GUI_FRONTEND_SERVICES=>FILE_COPY
EXPORTING
SOURCE = 'C:\Users\Danish\Desktop\test1.xlsx'
DESTINATION = 'C:\Users\Danish\Desktop\test2.xls'
EXCEPTIONS
CNTL_ERROR = 1
ERROR_NO_GUI = 2
WRONG_PARAMETER = 3
DISK_FULL = 4
ACCESS_DENIED = 5
FILE_NOT_FOUND = 6
DESTINATION_EXISTS = 7
UNKNOWN_ERROR = 8
PATH_NOT_FOUND = 9
DISK_WRITE_PROTECT = 10
DRIVE_NOT_READY = 11
NOT_SUPPORTED_BY_GUI = 12
OTHERS = 13.
IF SY-SUBRC NE 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
Regards,
Danish