Int li_row, li_rowcount
Int li_xlsrow, li_xlsrowcount
Int li_connect, li_ret
String ls_path, ls_filename
String ls_class, ls_id, ls_name
String ls_xblimit, ls_lxlimit
String ls_pym
Oleobject excelserver
Li_ret = getfileopenname ('select an Excel file', ls_path, ls_filename, "xls", "Excel (*. xls; *. XLSX), *. xls; *. XLSX ")
If li_ret <> 1 then return-1
F_prompt ("connecting to excel. application ")
Excelserver = create oleobject
/* Connect to the Excel Service */
Li_connect = excelserver. connecttonewobject ("Excel. application ")
If li_connect <0 then
MessageBox ("prompt! "," An error occurred while connecting to the Excel. application! ")
Return-1
End if
F_prompt ("Open Excel document ")
Excelserver. workbooks. Open (ls_path)
/* Whether to warn the user when closing the file. */
Excelserver. application. displayalerts = false
Excelserver. activeworkbook. worksheets (2). Select ()
Li_xlsrowcount = excelserver. activesheet. usedrange. Rows. Count
If li_xlsrowcount <= 0 then return-1
For li_xlsrow = 1 to li_xlsrowcount
Yield ()
F_prompt ("import" + ls_id + "-" + ls_name)
Ls_class = string (excelserver. activesheet. cells (li_xlsrow, 1). value)
Ls_id = string (excelserver. activesheet. cells (li_xlsrow, 2). value)
Ls_name = string (excelserver. activesheet. cells (li_xlsrow, 3). value)
Ls_xblimit = string (excelserver. activesheet. cells (li_xlsrow, 4). value)
Ls_lxlimit = string (excelserver. activesheet. cells (li_xlsrow, 5). value)
Ls_pym = f_getpy (ls_name)
Li_row = dw_import.insertrow (0)
Dw_import.setitem (li_row, 'class', ls_class)
Dw_import.setitem (li_row, 'id', ls_id)
Dw_import.setitem (li_row, 'name', ls_name)
Dw_import.setitem (li_row, 'xblimit ', ls_xblimit)
Dw_import.setitem (li_row, 'lxlimit ', ls_lxlimit)
Dw_import.setitem (li_row, 'pym', ls_pym)
Next
F_prompt ("Close Excel document ")
Excelserver. activeworkbook. Close ()
Excelserver. Quit ()
Excelserver. disconnectobject ()
Destroy excelserver
F_prompt ("")
MessageBox ("prompt", "Import complete! ")
Return 1