此文转载自:https://blog.csdn.net/m0_48322166/article/details/113181576

解决办法:使用Dbase格式进行下载,此格式会解决大部分Excel下载问题,是单元格形式(不知道这么解释对不对)。
FILENAME参数下载地址
FILETYPE参数更多格式可去function中查看,有详细描述。

‘DBF’ : 解释

Data is downloaded in dBase format. Since in this format the data types of the individual columns are stored as well, you can often avoid import problems, for example, into Microsoft Excel, especially when interpreting numeric values.

CODEPAGE参数是指语言,如果系统中有中文,使用错误代码,下载Excel会乱码,可根据function SCP_CODEPAGE_BY_EXTERNAL_NAME来寻找4位代码。

FIELDNAMES参数表头(此格式表头是列格式)

CALL FUNCTION ‘GUI_DOWNLOAD’
EXPORTING
filename = t_down
filetype = ‘DBF’
codepage = ‘8300’
TABLES
data_tab = itab2
fieldnames = itab1_text
EXCEPTIONS
file_write_error = 1
no_batch = 2
gui_refuse_filetransfer = 3
invalid_type = 4
no_authority = 5
unknown_error = 6
header_not_allowed = 7
separator_not_allowed = 8
filesize_not_allowed = 9
header_too_long = 10
dp_error_create = 11
dp_error_send = 12
dp_error_write = 13
unknown_dp_error = 14
access_denied = 15
dp_out_of_memory = 16
disk_full = 17
dp_timeout = 18
file_not_found = 19
dataprovider_exception = 20
control_flush_error = 21
OTHERS = 22.

  这样就可以解决引号的问题还会保留正确的数据。 
  随享笔记          2021/01/26 上海 阴。

相关文章: