cancel
Showing results for 
Search instead for 
Did you mean: 

Warning while downloading an Excel file from WD ABAP

Former Member
0 Kudos

Hi folks,

In one of requirements, Client wants to download all the data that is appearing on the screen ( WD ABAP Application ) to an Excel with a layout in different manner.

We achieved this with Simple Transformations.

Now the question is while downloading the excel file, the framework/other is throwing an Warning like

" The file you are trying to open, 'info.xls', is in a different format than specified by the extension. Verify that the file is not corrupted and is from a trusted source before opening the file. Do you want to open the file now? "

Note: All the users of my client are using MS Office 2002 / 2003.

I am using the following code........!

*------ Call Transformation for Excel OUTPUT

CALL TRANSFORMATION ZEXCEL_OUTPUT

SOURCE

t_dates = t_dates

t_info = t_info

RESULT XML l_xml_string.

REPLACE ALL OCCURRENCES OF '<?xml version="1.0" encoding="utf-16"?>' l_xml_string WITH '<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?>'.

**-- Call Function Module for converting string data to XSTRING

CALL FUNCTION 'SCMS_STRING_TO_XSTRING'

EXPORTING

text = l_xml_string

mimetype = 'application/xml'

IMPORTING

buffer = l_xml_xstring

EXCEPTIONS

failed = 1

OTHERS = 2.

CALL METHOD cl_wd_runtime_services=>attach_file_to_response

EXPORTING

i_filename = 'info.xml'

i_content = l_xml_xstring

i_mime_type = 'application/vnd.ms-excel'.

With this code I am generating a file of type XML SPREADSHEET 2003. While opening this file I am getting the above message which the user unwanted......

Can any one help me on this -


> How to avoid this warning?

Thanks and Regards,

Aneel Danda

Edited by: danda aneel on Jul 13, 2010 1:43 PM

Accepted Solutions (0)

Answers (2)

Answers (2)

Former Member
0 Kudos

Hello,

Did you find a solution ? I getting similar error and tried them all too....do let me know if you still remember.

Thanks.

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

When you get the error, does it say info.xls or info.xml. Becuase in your source code sample you are using a filename of info.xml:

CALL METHOD cl_wd_runtime_services=>attach_file_to_response

EXPORTING

i_filename = 'info.xml'

i_content = l_xml_xstring

i_mime_type = 'application/vnd.ms-excel'.

According to the Microsoft KB, this error is produced when the mime type doesn't match the file extension. XML doesn't seem like it would match the 'application/vnd.ms-excel'.

The other thing to consider is that I believe that Office Expects UTF-8 for the XML format and from your snippet, you seem to be using UTF-16.

Former Member
0 Kudos

Firstly, Thanks for Your quick Response, Thomas.

Even though what ever may be the file name I am passing either info.xml or Info.xls , In error info.xls is coming.

Kindly provide me an alternative on this XML doesn't seem like it would match the 'application/vnd.ms-excel'.

what is the supported format.?

Similarly, It is not considering the UTF-8 / UTF-16 for xml.........same result is appearing in the output.

Edited by: danda aneel on Jul 14, 2010 7:52 AM

ChrisPaine
Active Contributor
0 Kudos

>XML doesn't seem like it would match the 'application/vnd.ms-excel'

you're providing an XML file - but suggesting it is different mime type (a MS Excel file).

Type "application/xhtml+xml" might be a better match.