Показать сообщение отдельно
Старый 26.07.2011, 15:21   #2  
Gustav is offline
Gustav
Moderator
Аватар для Gustav
SAP
Лучший по профессии 2009
 
1,858 / 1152 (42) ++++++++
Регистрация: 24.01.2006
Адрес: Санкт-Петербург
Записей в блоге: 19
Цитата:
Сообщение от GBH Посмотреть сообщение
Но не могу понять, как обрабатывать файл после того как доступ получен.
Читать строка за строкой, поле за полем в цикле. Там же в 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();