1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
|
private static void FileParse(object file)
{
IList<string> lStr1 = new List<string>();
OleDbConnection MyConnection;
MyConnection = new OleDbConnection("provider=Microsoft.Jet.OLEDB.4.0;data source=" + file + ";Extended Properties=Excel 5.0;");
DbCommand command = MyConnection.CreateCommand();
command.CommandText = "SELECT Country FROM [Detail EMEA $]";
MyConnection.Open();
lStr1.Add("Country");
using (DbDataReader dr = command.ExecuteReader())
{
while (dr.Read())
{
lStr1.Add(dr[0].ToString().ToUpper() );
}
}
MyConnection.Close();
System.Console.WriteLine("");
System.Console.WriteLine("Debut sauvegarde fichier : " + path);
if (File.Exists(path))
File.Delete(path);
WriteInFile(path, lStr1);
System.Console.WriteLine("");
System.Console.WriteLine("Sauvegarde fichier Ok");
System.Console.WriteLine("");
} |
Partager