2024 Oct 25 5:22 PM - edited 2024 Oct 25 5:23 PM
I am using GUI_DOWNLOAD to download internal table data as Excel file, however while opening the file getting popup as
"The file format and extension of ABC.xls’ don’t match. This file could be corrupted or unsafe. Unless you trust its source, don’t open it. Do you want to open it anyway?"
Can we remove this popup using ABAP coding? please let me know.
CLEAR P_FILE .
CONCATENATE P_FILE2 '\' LS_EKKO-EBELN '.xls' INTO P_FILE.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = P_FILE
filetype = 'ASC'
write_field_separator = 'X'
TABLES
data_tab = LT_PO_EXCEL
fieldnames = lt_header .
Request clarification before answering.
Basically, Excel is warning you because you haven't generated an actual XLS, XLSX or CSV file with GUI_DOWNLOAD (or CL_GUI_FRONTEND_SERVICES=>GUI_DOWNLOAD).
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Raymond,
Thanks for your response,
I have changed file name as .csv and passed below parameters to GUI_DOWNLOAD.
CODEPAGE = '4103'
WRITE_BOM = 'X' REPORT ZTRY_CSV.
TYPE-POOLS: truxs.
TYPES:
BEGIN OF ty_Line,
vbeln LIKE vbap-vbeln,
posnr LIKE vbap-posnr,
END OF ty_Line.
DATA: itab TYPE table of ty_Line.
SELECT
vbeln
posnr
UP TO 10 ROWS
FROM vbap
INTO TABLE itab.
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = 'D:\TEMP\DEMO1.CSV'
filetype = 'ASC'
write_field_separator = ',' " OR 'X'
CODEPAGE = '4103'
WRITE_BOM = 'X'
TABLES
data_tab = itab
* fieldnames = lt_header .
.
This code is generating Micro soft excel file with comma separator and creating separate columns for each field.
Actually, this is a text file with tab delimiter 😎
@Subbaka11"this is a text file with tab delimiter" ... which is not intended to be used in a file named with the extension .xls (https://en.wikipedia.org/wiki/Microsoft_Excel "File formats -- Up until the 2007 version, Microsoft Excel used a proprietary binary file format called Excel Binary File Format (.XLS)")
| User | Count |
|---|---|
| 7 | |
| 6 | |
| 6 | |
| 5 | |
| 4 | |
| 3 | |
| 3 | |
| 3 | |
| 3 | |
| 3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.