view plaincopy to clipboardPRint? ·········10········20········30········40········50········60········70········80········90········100·······110·······120·······130·······140·······150 using System; using System.Collections.Generic; using System.Text; using System.Data.OleDb; using System.Data;
namespace MyExcel { public class ExcelConnector { string connString; public ExcelService(string path) { connString = "Provider=Microsoft.Jet.OLEDB.4.0;" + "Data Source=" + path + ";" + "Extended Properties=Excel 8.0;"; }
private OleDbConnection conn; public OleDbConnection Connection { get {
if (conn == null) { conn = new OleDbConnection(connString); conn.Open(); } else if (conn.State == ConnectionState.Broken) { conn.Close(); conn.Open(); } else if (conn.State == ConnectionState.Closed) { conn = new OleDbConnection(connString); conn.Open(); } return conn; }