13.05.2007, 17:12 | #1 |
Участник
|
casperkamal: Using ADO to read from Excel in Microsoft Dynamics Ax
Источник: http://casperkamal.spaces.live.com/B...CD63!288.entry
============== Sometime back i had a posting referring to Gloomies blog (click to see the old posting) on using ADO in Ax. Gloomie had used COM based ADO control. Ax also has predefined ADO Com classes which you can use.... Here's a small Job that will help you in working with the Inbuild ADO classes static void JobADOtoAccessExcelInAxapta(Args _args) { CCADOConnection adoexcel = new CCADOConnection(); CCAdoxCatalog adoCatalog = new CCAdoxCatalog(); COM adoxCatalog = new COM('ADOX.Catalog'); CCADORecordSet adoRecordSet = new CCADORecordSet(); CCADOFields adoFields; CCADOField adoField; int i; ; adoexcel.connectionString("Provider=Microsoft.Jet.OLEDB.4.0;Data Source= C:\TestAdo.xls ;Extended Properties='Excel 8.0;HDR=Yes;IMEX=1'"); adoexcel.open(); adoxCatalog.activeConnection(adoexcel.connection()); adoCatalog.adoxCatalog(adoxCatalog); print adoCatalog.tableName(1); pause; adoRecordSet.open(@"SELECT * FROM [SHEET1$]", adoexcel); adoFields = adoRecordSet.fields(); for (i = 0; i < adoFields.count(); i++) { adoField = adoFields.itemIdx(i); print adoField.name(); pause; } while (! adoRecordSet.EOF()) { for (i = 0; i < adoFields.count(); i++) { adoField = adoFields.itemIdx(i); print adoField.value(); pause; } adoRecordSet.moveNext(); } } Here is a snap shot of the excel that i used for the job.... .................. Keep watching while I post more on this ... Источник: http://casperkamal.spaces.live.com/B...CD63!288.entry
__________________
Расскажите о новых и интересных блогах по Microsoft Dynamics, напишите личное сообщение администратору. |
|
14.05.2007, 11:53 | #2 |
SAP
|
Вот меня всегда интересовал вопрос как правельно наложить фильтр на запрос
X++: adoRecordSet.open(@"SELECT * FROM [SHEET1$]", adoexcel); |
|
14.05.2007, 11:59 | #3 |
Участник
|
Вырезка кода из Jobs (тестовых) проекта Gustav - ImportFromOfficeDB
X++: // cool real SQL-query to Excel sheet !!! have you ever dreamt about it ?! doc.setRecordSource( 'SELECT * FROM [EmplTable$] WHERE Left([Name],1) IN ' + '( ' + ' SELECT TOP 1 FirstLetter FROM ' + ' ( ' + ' SELECT TOP 3 FirstLetter, Count(*) AS CountOfFirstLetter ' + ' FROM ' + ' ( ' + ' SELECT Left([Name],1) AS FirstLetter, [EmplTable$].* ' + ' FROM [EmplTable$] ' + ' ) ' + ' GROUP BY FirstLetter ' + ' ORDER BY Count(*) DESC ' + ' ) ' + ' ORDER BY CountOfFirstLetter ' + ') ' ); // this query returns subset of records from worksheet EmplTable, // in which every name of employee starts with character, // which is on 3rd position in rank of more popular first characters in Name field (Oh Mein Got! :-)) |
|
|
|