static void LoadExcelFile(string file, string sheet) { // Use this connection string template for older (pre-2007) version of Excel //string s = @"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + file // + ";Extended Properties=Excel 8.0"; // Use this connection string template for Excel 2007 string s = @"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" + file + ";Extended Properties=\"Excel 12.0 Xml;HDR=YES\";"; OleDbConnection conn = new OleDbConnection(s); OleDbDataAdapter da = new OleDbDataAdapter("select * from [" + sheet + "$]", conn); DataTable dt = new DataTable(); da.Fill(dt); }
ScrewTurn Wiki version 3.0.1.400. Some of the icons created by FamFamFam. Except where noted, all contents Copyright © 1999-2024, Patrick Jasinski.