REPORT z_barry_test NO STANDARD PAGE HEADING LINE-SIZE 240.
DATA: BEGIN OF itab OCCURS 0,
ff1(10) TYPE c,
ff2(10) TYPE n,
ff3 TYPE d,
ff4 TYPE t,
ff5 TYPE p DECIMALS 2,
END OF itab.
DATA: BEGIN OF itab_field OCCURS 0,
fname(40) TYPE c ,
END OF itab_field.
itab-ff1 = '测试ABC'.
itab-ff2 = '1234'.
itab-ff3 = '20100120'.
itab-ff4 = '163145'.
itab-ff5 = '13244.34'.
APPEND itab.
itab_field-fname = 'F1'.
APPEND itab_field.
itab_field-fname = 'F2'.
APPEND itab_field.
itab_field-fname = 'F3'.
APPEND itab_field.
itab_field-fname = 'F4'.
APPEND itab_field.
itab_field-fname = '5'. "针对非C、N、D、T类型列的列名,函数有Bug
APPEND itab_field.
CALL FUNCTION 'EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = 'C:\TEST1'
create_pivot = 0
data_sheet_name = 'TEST 1'
TABLES
data_tab = itab
fieldnames = itab_field
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
OTHERS = 9.
CALL FUNCTION 'MS_EXCEL_OLE_STANDARD_DAT'
EXPORTING
file_name = 'C:\TEST2'
data_sheet_name = 'TEST 2'
TABLES
data_tab = itab
fieldnames = itab_field
EXCEPTIONS
file_not_exist = 1
filename_expected = 2
communication_error = 3
ole_object_method_error = 4
ole_object_property_error = 5
invalid_filename = 6
invalid_pivot_fields = 7
download_problem = 8
OTHERS = 9.
Bug有两个:
1、Fieldname数据类型会被强制转变为对应列的类型,如果转换失败则Dump
2、如果连续两次或两次以上以上调用,列名会跑到数据区
另外,如果要导出的数据有中文且本机操作系统不是中文,则GUI须用中文登录
阅读(4716) | 评论(4) | 转发(0) |