上传XLS文件:
先将XLS保存成TXT文件,然后用WS_UPLOAD或UPLOAD函数上传。注意FILETYPE参数=‘DAT’。
CALL FUNCTION 'UPLOAD'
EXPORTING
CODEPAGE = 'IBM'
FILENAME = 'd:/temp/mytable.txt'
FILETYPE = 'DAT'
ITEM = 'Read Test for Excel File'
IMPORTING
FILESIZE = FSIZE
ACT_FILENAME = FNAME
ACT_FILETYPE = FTYPE
TABLES
DATA_TAB = TAB
EXCEPTIONS
CONVERSION_ERROR = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3.
下载XLS文件:
WS_DOWNLOAD或DOWNLOAD函数可以直接将内表保存为XLS文件。
CALL FUNCTION 'DOWNLOAD'
EXPORTING
CODEPAGE = 'IBM'
FILENAME = 'd:/temp/saptest.xls'
FILETYPE = 'DAT'
ITEM = 'Test for Excel File'
IMPORTING
ACT_FILENAME = FNAME
ACT_FILETYPE = FTYPE
FILESIZE = FSIZE
TABLES
DATA_TAB = TAB
EXCEPTIONS
INVALID_FILESIZE = 1
INVALID_TABLE_WIDTH = 2
INVALID_TYPE = 3.