on 2025 Oct 13 3:50 PM
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!
Request clarification before answering.
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:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 17 | |
| 8 | |
| 8 | |
| 6 | |
| 4 | |
| 4 | |
| 3 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.