FUNCTION zps_get_excel_sheetname.
*"----------------------------------------------------------------------
*"*"本地接口:
*" IMPORTING
*" VALUE(IV_FILE) LIKE RLGRAP-FILENAME OPTIONAL
*" TABLES
*" ET_SHEETNAME STRUCTURE ZSPS_SHEETNAME OPTIONAL
*"----------------------------------------------------------------------
DATA:ls_sheetname LIKE LINE OF et_sheetname.
DATA: application TYPE ole2_object,
book TYPE ole2_object,
sheet TYPE ole2_object.
DATA: sheetcount TYPE i .
INCLUDE ole2incl.
*清空输出参数
REFRESH:et_sheetname.
CREATE OBJECT application 'Excel.Application'.
SET PROPERTY OF application 'Visible' = 0 .
CALL METHOD OF application 'Workbooks' = book.
CALL METHOD OF book 'Open'
EXPORTING
#1 = iv_file.
CALL METHOD OF application 'WORKSHEETS' = sheet.
GET PROPERTY OF sheet 'COUNT' = sheetcount.
DO sheetcount TIMES.
CALL METHOD OF application 'WORKSHEETS' = sheet
EXPORTING #1 = sy-index.
GET PROPERTY OF sheet 'NAME' = ls_sheetname-sheetn .
APPEND ls_sheetname TO et_sheetname.
ENDDO.
GET PROPERTY OF application 'ActiveWorkbook' = book .
CALL METHOD OF book 'close'.
CALL METHOD OF application 'QUIT'.
ENDFUNCTION.
阅读(1382) | 评论(0) | 转发(0) |