问题描述
我需要通过 SAPGUI 读取 excel 文件(不是批量读取,也不是从服务器读取).只有一张纸/文件,而不是 csv 文件.
I need to read excel files via SAPGUI (not in batch, not from server).Only one sheet/file, not a csv file.
我知道有一些功能模块可以做到这一点,但它们的单元格大小限制为每个单元格 32、40 或 50 个字符.
I am aware of a few function modules that do that, but they are restricted to cell sizes of 32 or 40 or 50 characters per cell.
是否有功能模块或类/方法可以让我读取带有更长单元格的 excel 文件?更长的意思是:要么是字符串,要么是调用者定义的,或者至少是 80.
Are there function modules or classes/methods that allow me to read excel files with longer cells?Longer means: either String or defined by the caller or at least 80.
编辑
我在其他单元格大小不那么重要的项目中成功使用了 ALSM_EXCEL_TO_INTERNAL_TABLE.该模块读入一个结构 ALSMEX_TABLINE,该结构将数据限制为 50 个字符.
I used ALSM_EXCEL_TO_INTERNAL_TABLE successfully in other projects where cell size is not that important. This module reads into a structure ALSMEX_TABLINE that restricts data to 50 characters.
KCD_EXCEL_OLE_TO_INT_CONVERT 读入 32 个字符/单元格的表格.
KCD_EXCEL_OLE_TO_INT_CONVERT reads into a table with 32 characters / cell.
推荐答案
您可以将 FILE_READ_AND_CONVERT_SAP_DATA
用于该目的.它的输出表格单元格限制为 256 个字符,这对您来说已经足够了.代码示例如下:
You can use FILE_READ_AND_CONVERT_SAP_DATA
for that aim. Its output table cell is limited to 256 characters, which would be quite sufficient for you. Code sample is given below:
TYPES: tv_data(256) TYPE c,
BEGIN OF ts_data,
value_0001 TYPE tv_data,
...
value_0020 TYPE tv_data,
END OF ts_data,
tt_data TYPE TABLE OF ts_data.
DATA: lv_fname TYPE filename-fileintern,
pt_data TYPE tt_data.
lv_fname = 'C: est.xls'.
CALL FUNCTION 'FILE_READ_AND_CONVERT_SAP_DATA'
EXPORTING
i_filename = lv_fname
i_servertyp = 'OLE2'
i_fileformat = 'XLS'
TABLES
i_tab_receiver = pt_data
EXCEPTIONS
file_not_found = 1
close_failed = 2
authorization_failed = 3
open_failed = 4
conversion_failed = 5
OTHERS = 6.
IF sy-subrc <> 0.
* error handling
ENDIF.
这篇关于从前端加载具有 80 多个字符的单元格值的 xls的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!