ABAP XML填充Excel表单
- 设定Excel模板样式–(一 般业务顾问提供),如下图所示
- 转化文件格式,另存为XML格式(用记事本或者浏览器就可以看到xml的格式样式)
- 更改抬头,添加引用
'<?xml version="1.0"?>'
'<?mso-application progid="Excel.Sheet"?>'
'<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel'
'" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40">'
'<DocumentProperties xmlns="urn:schemas-microsoft-com:office:office">'
'<Created>2006-09-13T11:21:51Z</Created>'
'<LastSaved>2013-10-18T02:31:28Z</LastSaved>'
'<Version>12.00</Version>'
'</DocumentProperties>'
'<OfficeDocumentSettings xmlns="urn:schemas-microsoft-com:office:office">'
'<RemovePersonalInformation/>'
'</OfficeDocumentSettings>'
'<ExcelWorkbook xmlns="urn:schemas-microsoft-com:office:excel">'
'<WindowHeight>7890</WindowHeight>'
'<WindowWidth>19200</WindowWidth>'
'<WindowTopX>0</WindowTopX>'
'<WindowTopY>90</WindowTopY>'
'<ProtectStructure>False</ProtectStructure>'
'<ProtectWindows>False</ProtectWindows>'
'</ExcelWorkbook>'
4.xml拼接处理完成后,用函数GUI_DOWNLOAD输出(XML拼接放入LT_XML_TAB中)
CALL FUNCTION 'GUI_DOWNLOAD'
EXPORTING
filename = gv_filename
filetype = 'DAT'
codepage = '4110'
TABLES
data_tab = LT_XML_TAB
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.
IF sy-subrc = 0.
* PERFORM sub_ole2_processing USING p_fpath.
ELSE.
MESSAGE ID sy-msgid TYPE 'S' NUMBER sy-msgno
WITH sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4 DISPLAY LIKE 'E'.
ENDIF.