static void Main(string[] args) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); String file = @"C:\Users\Uther\Desktop\РАФ\УССО_30_01.xlsx"; String path2 = @"C:\Users\Uther\Desktop\РАФ\NotValid.xlsx"; bool InDiffLists = false; var dataSet = ReadExcel.GetDataSetFromExcelFile(file); Console.WriteLine(string.Format("reading file: {0}", file)); Console.WriteLine(string.Format("coloums: {0}", dataSet.Tables[0].Columns.Count)); Console.WriteLine(string.Format("rows: {0}", dataSet.Tables[0].Rows.Count)); var lists = DataIntoList.IntoList(dataSet); var NotValidList = lists.Item2; FileStream objFileStrm = File.Create(path2); objFileStrm.Close(); WriteExcel.SetDataSetFromExcelFile(InDiffLists, NotValidList, path2);//NotValid into Excel var RowObjInfoListJSON = DataIntoList.IntoJList(lists.Item1); //var json = JsonConvert.SerializeObject(RowObjInfoListJSON, Formatting.Indented); int count = lists.Item1.Count; JSON.ToJSON(count, RowObjInfoListJSON); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; // Format and display the TimeSpan value. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); Console.WriteLine("RunTime " + elapsedTime); Console.WriteLine(lists.Item1.Count); Console.ReadKey(); }
public static void Main(string[] args) { // Read(@"D:\document\gtx.docx"); WriteExcel.inputExcel(); }
public void CreazioneLtturaFile() { //in primo luogo mi creo un ambiente pulito string p = @"C:\\temp\test"; string fileName = @"OutputTest"; if (!Directory.Exists(p)) { Directory.CreateDirectory(p); } foreach (FileInfo file in new DirectoryInfo(p).GetFiles()) { if (file.Name.Contains(fileName)) { file.Delete(); } } //parto List <provaIniezioneClasse> tmList = new List <provaIniezioneClasse>(); provaIniezioneClasse tm = new provaIniezioneClasse(); tm.prova1 = 1; tm.prova2 = "prova2"; tm.prova3 = "prova3 1 time"; tm.TestDate = DateTime.Now.Date; tmList.Add(tm); provaIniezioneClasse tm2 = new provaIniezioneClasse(); tm2.prova1 = 123; tm2.prova2 = "prova2"; tm2.prova3 = "prova3 1 time"; tm2.TestDate = DateTime.UtcNow; tmList.Add(tm2); provaIniezioneClasse tm3 = new provaIniezioneClasse(); tm3.prova2 = "prova2"; tmList.Add(tm3); WriteExcel wr = new WriteExcel(); wr.WriteExcelFile(tmList, p, fileName); Assert.IsTrue(File.Exists(Path.Combine(p, fileName + ".xlsx")));//l'ho creato è già cosa buona e giusta ReadEcxel rd = new ReadEcxel(); DataTable read = new DataTable(); rd.ReadEcxelFile(out read, p, fileName); Assert.IsTrue(tmList.Count == read.Rows.Count);// int i = 0; foreach (DataRow rows in read.Rows) { provaIniezioneClasse tmp = tmList[i++]; Assert.IsTrue(rows[0].ToString() == tmp.prova1.ToString()); Assert.IsTrue((rows[1].ToString() == "" && string.IsNullOrEmpty(tmp.prova2)) || (rows[1].ToString() == tmp.prova2.ToString())); Assert.IsTrue((rows[2].ToString() == "" && string.IsNullOrEmpty(tmp.prova3)) || (rows[2].ToString() == tmp.prova3.ToString())); Assert.IsTrue((tmp.TestDate != DateTime.MinValue && rows[3].ToString() == tmp.TestDate.ToString()) || (tmp.TestDate == DateTime.MinValue && rows[3].ToString() == "")); } // adesso lo rileggo e confronto il contenuto }