Monday, 15 February 2010

c# - Solve OLE DB Connection without install Data Connectivity Components -


Is there a way to resolve the problem of the OLEDB connection (microsoft.ace.oledb.12.0 'provider? Local machine) When reading an Excel file

please advise.

Use the code

  using the system; Using System.IO; Using the system. Using NUnit.Fraamework; Using ExcelTools = Ms.Office; Using Excel = Microsoft.Office.Interop.Excel; Namespace Test {{TestFixture} Public Class ExcelSingle {[Test} Public Nine ProcessWorkbook () {string file = @ "C: \ Users \ Chris \ Desktop \ TestSheet.xls"; Console.WriteLine (file); Excel.Application excel = null; Excel Workbook wkb = null; Try Excel {new Excel.Application (); Wkb = ExcelTools.OfficeUtil.OpenBook (excel, file); Excel.Worksheet sheet = wkb.Sheets ["Data"] Excel.Worksheet; Excel Range range = null; If (sheet! = Null) category = sheet.get_range ("A1", lost value); String A1 = string Empty; If (category! = Zero) A1 = category Lesson Toasting (); Console.light line ("A1 value: {0}", A1); } Hold (Exception Pre) {// If you want to handle the Accessories console WrightLine (ex.Message); } Finally {if (wkb! = Tap) ExcelTools.OfficeUtil.ReleaseRCM (wkb); If (excel! = Null) ExcelTools.OfficeUtil.ReleaseRCM (Excel); }}}}    

No comments:

Post a Comment