Read from Excel with OLEDB

lape
Member Posts: 19
Is it possible to Create an OLEDB Connection to an Excel Sheet and Read the Tables from the SchemaTable via DotNet Datatype?
I tryed the following:
in C# i can do it like this:
...
I tryed the following:
ConnectionString := 'Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\temp\test.xls;Extended Properties="Excel 8.0;HDR=YES";'; OLEConnect := OLEConnect.OleDbConnection(ConnectionString); OLEConnect.Open();...
in C# i can do it like this:
DataTable sheets = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] {null, null, null, "TABLE"});but in Dynamics the method table not avalible
...
OLEConnect.Close();
0
Comments
-
HI Lape,
that's a pretty cool idea. I don't know how to solve it, but I hope you solve it, as I would like to try this also. I can see quite a few uses for this. Especially for automation projects where Excel is not installed.
Also a question. Do you think this would be faster than using excel automations? I have a lot of cases where clients have huge spread sheets that take quite some time to import or export.David Singleton0 -
Hi,
you can alternatively use following code to retrieve the sheet/tablenames:lSheetName := 'Tabelle1$'; lSchemaTable := lOleDbConnection.GetSchema('Tables'); IF lSchemaTable.Rows.Count > 0 THEN BEGIN lDataRow := lSchemaTable.Rows.Item(0); lSheetName := lDataRow.Item(2); END;
0 -
-
hi,
this was meant as alternative for the missing to do something likeDataTable sheets = con.GetOleDbSchemaTable(OleDbSchemaGuid.Tables, new object[] {null, null, null, "TABLE"});
in c/al, if you don't know the names of the included worksheets.
the example retrieves the name of the 1st sheet.0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions