// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.Data.OleDb; class MainClass { public static void Main(string[] args) { OleDbConnection con = new OleDbConnection( @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=C:\Book2.xls;Extended Properties=""Excel 8.0;HDR=Yes;IMEX=1"""); con.Open(); OleDbCommand cmd = new OleDbCommand("SELECT k2,k3 FROM [sheet1$] WHERE k1 >= 2", con); OleDbDataReader rdr = cmd.ExecuteReader(); while(rdr.Read()) { double k2 = (double)rdr[0]; double k3 = (double)rdr[1]; Console.WriteLine(k2 + " " + k3); } con.Close(); } }