cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Need help to generate and send a true Excel file via email in ABAP

neha_maven
Explorer
0 Kudos
500

Hello Experts,

I have developed an ABAP program that sends an email with an attachment in Excel format. The internal table data is being successfully converted and sent as an Excel file. However, when the recipient opens the file, the following message appears:

“The file format and extension of [filename] don’t match. The file could be corrupted or unsafe. Unless you trust its source, don’t open it. Do you want to open it anyway?”

Although the file opens correctly after confirming, the client requires the attachment to be a true Excel file (without this warning message).

Currently, I am generating the Excel by converting internal table data into a tab-delimited or comma-separated format and saving it with a .xls or .xlsx extension before attaching it to the email. I understand that this only creates a text file readable by Excel, but not a genuine Excel binary or XML file.

Could anyone please suggest the best approach to generate a true Excel file (either .xlsx format or similar) directly in ABAP and send it as an email attachment?
Are there any standard SAP classes or recommended methods (like cl_fdt_xl_spreadsheet or other approaches) to achieve this?

Any guidance or example code would be highly appreciated.
Thank you in advance for your help!

Accepted Solutions (0)

Answers (1)

Answers (1)

abo
Active Contributor

The fact that an end-user might mistake a CSV for an XLSX file just because Excel opens when double-clicking a CSV file (a Windows behaviour) is unfortunate but excusable. That a technical person also confuses them, to the point of renaming it, not as much: Excel is simply telling you that the extension (XLSX) does not match the file internal structure (CSV).

Depending on the level of tweaking your table requires before sending you could either:

chris_perkins4
Explorer
abap2xlsx is an amazing product and we use it all the time. It can get complicated though. I wrote a few wrapper classes to abstract most of the processing around reading, writing, and emailing the xlsx documents, and they cover everything you need to do 98% of the time. But if you need to get super detailed with formatting and so on, the tools are there. OP should definitely check it out.
neha_maven
Explorer
0 Kudos
Client doesn't want to install abap2xls