![]() |
#2 |
Moderator
|
Читать строка за строкой, поле за полем в цикле. Там же в classDeclaration подробнейшим образом в каментах всё расписано:
Цитата:
#// gl00mie, import data from Excel via ADO, 20061220 -->
#// How to use this class: #// 1. Create class instance, specify filename and (optional) cursor type e.g. #// doc = new ExcelImportADO(strFilename, #adOpenStatic); #// 2. Read names of worksheets present in the file, suppress error messages if necessary #// con = doc.getExcelSheetNames(); #// 3. Specify the name of the worksheet to open ADODB.Recordset on, otherwise the first one will be used #// doc.excelSheetName(conpeek(con,2)); #// 4. Open the file, i.e. open ADODB.Recordset (and ADODB.Connection if it's not opened yet) #// suppress error messages if necessary and check for result: #// if(doc.openFile(false)) ... #// 5. Check if there is a correct number of columns in the Recordset #// if(doc.getFieldsCount() > 7) ... #// 6. Get the total record count if #adOpenStatic cursor type is used #// cnRecords = doc.getRecordCount(); #// 7. Read records in a loop, use indexes (1..n) or field names to identify fields #// By default field values are returned as strings #// int i; #// real r; #// str s; #// while(!doc.eof()) #// { #// i = doc.getFieldValue(1, false); #// s = doc.getFieldValue('stringField'); #// r = doc.getFieldValue('numericField', false); #// doc.moveNext(); #// } #// 8. Cleanup - close ADODB.Recordset and ADODB.Connection #// doc.finalize(); |
|