void clicked() { SysExcelApplication Excel; SysExcelWorkbooks Books; SysExcelWorkbook Book; SysExcelWorksheets Sheets; SysExcelWorksheet Sheet; SysExcelCells Cells; SysExcelCell Cell; SysExcelStyles Styles; SysExcelStyle Style; int RowCount,RecNum,n; Filename _FilenameOpen; XYF_ContactsTable _ContactsTable; Dialog _Dialog; DialogField dlgPath; DictEnum DictEnum ; _Dialog = new Dialog('Import ......'); dlgPath = _Dialog.addField(typeid(FilenameOpen)); DictEnum = new DictEnum(EnumName2Id('XYF_ContacstsType')); _Dialog.doInit(); if(_Dialog.run()) { try { _FilenameOpen = dlgPath.value(); Excel = SysExcelApplication::construct(); Books = Excel.workbooks(); Books.open(_FilenameOpen,true); Book = Books.item(1); Sheets = Book.worksheets(); Sheet = Sheets.itemFromNum(1); Cells = Sheet.cells(); delete_from _ContactsTable; RowCount = 2; //从第二行开始取数据,第一行存放字段名. for(RowCount = 2;Cells.item(RowCount,1).value().bStr() != "";RowCount++) { RecNum++; n = 1; _ContactsTable.Name = Cells.item(RowCount,n).value().bStr(); n++; _ContactsTable.NameAlias = Cells.item(RowCount,n).value().bStr(); n++; _ContactsTable.Tel = Cells.item(RowCount,n).value().bStr(); if(!_ContactsTable.Tel) _ContactsTable.Tel = Cells.item(RowCount,n).value().toString(); if(strscan(_ContactsTable.Tel,',',1,strlen(_ContactsTable.Tel))) _ContactsTable.Tel = StrReplace(_ContactsTable.Tel,',',''); if(strscan(_ContactsTable.Tel,'.',1,strlen(_ContactsTable.Tel))) _ContactsTable.Tel = StrReplace(_ContactsTable.Tel,'.',''); n++; _ContactsTable.Tel_Fixed = Cells.item(RowCount,n).value().bStr(); n++; _ContactsTable.QQ = Cells.item(RowCount,n).value().double(); n++; _ContactsTable.Email = Cells.item(RowCount,n).value().bStr(); n++; // _ContactsTable.XYF_ContacstsType = DictEnum.symbol2Value(Cells.item(RowCount,n). //symbol2Value英文名称转整型值 _ContactsTable.XYF_ContacstsType = DictEnum.name2Value(Cells.item(RowCount,n). value().bStr());//name2Value中文枚举的标签值转整形值 N++; _ContactsTable.Address = Cells.item(RowCount,n).value().bStr(); //n++; // _ContactsTable.Photo = Cells.item(RowCount,n).value().container(); if(_ContactsTable.Name != "") _ContactsTable.doinsert(); } } catch(Exception::Error) Excel.quit(); info(strfmt("Import into XYF_ContactsTable of %1 ",RecNum)); Excel.quit(); XYF_ContactsTable_ds.executeQuery(); XYF_ContactsTable_ds.research(); } }