abap中有多個函式處理上傳的excel文件中的資料,記錄資料的資訊(行、列、值)。
如,函式kcd_excel_ole_to_int_convert:
data: lt_data_in_file type table of kcde_cells,
ls_data_in_file type kcde_cells.
call function 'kcd_excel_ole_to_int_convert'
exporting
filename = g_file "上傳檔名(如:c:\users\chen\upload.xlsx)
i_begin_col = 1
i_begin_row = 1
i_end_col = 256
i_end_row = 65535
tables
intern = lt_data_in_file
exceptions
inconsistent_parameters = 1
upload_ole = 2
others = 3.
* if sy-subrc <> 0.
* message e160.
* endif.
我們將資料以行、列、值的方式儲存在內表lt_data_in_file中。
這裡需要注意的是:這裡的值儲存的文字長度為32。
所以當你上傳的資料值長度超過32的時候,它就自動擷取32個文字;
下面這個函式zalsm_excel_to_internal_table,可以接收50個上傳字元:
data: lt_data_in_file type table of zalsmex_tabline,
ls_data_in_file type zalsmex_tabline.
call function 'zalsm_excel_to_internal_table'
exporting
filename = p_file "上傳檔名
i_begin_col = '1'
i_begin_row = '1'
i_end_col = '256'
i_end_row = '10000'
tables
intern = lt_data_in_file.
* if sy-subrc <> 0.
** implement suitable error handling here
* endif.
上傳解析Excel
專案中上傳解析excel的功能,非常普遍,因為方便,接下來就寫乙個工具類對excel進行解析 引入poi 阿帕奇依賴 工具類的書寫public class excelutils else if excel 2007 suffix.equalsignorecase suffixname catch i...
上傳excel檔案,解析excel檔案
需要jxl.jar包 上傳excel檔案 獲取檔案字尾名 public static string getfileext string f return param excelfile 讀取檔案物件 param rownum 從第幾行開始讀,如果有一行表頭則從第二行開始讀 return throws...
poi上傳解析excel 上傳檔案
服務層進行處理 public void importexpressinformation multipartfile file throws exception 這裡我只需要三個單元格內的資料所以沒有迴圈單元格去取東西 for cell cell row id cell cell row.getce...