public void WriteData_to_Excell(string path, Dictionary <string, string> Data) { PB = new progress_bar(0, Data.Count); Console.WriteLine("Writing data to Excel file:"); if (System.IO.File.Exists(path)) { xlWorkBook = xlApp.Workbooks.Open(path, 0, false, 5, "", "", true, XlPlatform.xlWindows, "\t", false, false, 0, true, 1, 0); xlWorkSheet = (Worksheet)xlWorkBook.Worksheets.get_Item(1); i = 1; foreach (KeyValuePair <string, string> data_row in Data) { range = (Range)xlWorkSheet.Cells[i, 1]; range.Value = data_row.Key.ToString(); range = (Range)xlWorkSheet.Cells[i, 2]; range.Value = data_row.Value.ToString(); i++; redraw(); //Console.WriteLine(String.Format("info wrote: \t{0}:\t{1}", data_row.Key, data_row.Value)); //System.Threading.Thread.Sleep(500); } xlWorkBook.Save(); Console.WriteLine("\n\nExcel file saved"); GC.Collect(); GC.WaitForPendingFinalizers(); xlWorkBook.Close(true, false, false); Marshal.FinalReleaseComObject(xlWorkBook); } }
public static void create_pb(int max) { PB_HTML = new progress_bar(0, max); }