title: how to speed up excel interop process in c#
body: <p>Here is my code. Please help me friends. This code can convert any text document to excel. But in large documents it takes so much time. How do i solve  this?</p>
  
  <pre><code>Excel.Application xlApp = new Microsoft.Office.Interop.Excel.Application();
      Excel.Workbook xlWorkBook;
      Excel.Worksheet xlWorkSheet;
      xlApp.ScreenUpdating=false;
      object misValue = System.Reflection.Missing.Value;
      xlWorkBook = xlApp.Workbooks.Add(misValue);
      xlWorkSheet = (Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);
          FileInfo theSourceFile = new FileInfo(@"" + file); 
          StreamReader reader = theSourceFile.OpenText();
          int raw = 1; int column = 1; 
          String text = "";
            do
               {
                 text = reader.ReadLine();
                 if (text != null)
                    {
                      string[] ss = text.Split('|');
                      int index = 0; double result;
                      //WRITING DATA LINES
                      for (int i = 1; i &lt; ss.Length; i++)
                        {
                         if (!ss[index].Contains('.')) //recognising strings by filtering currency values using "." sign (decimal point)
                            {
                             xlWorkSheet.Cells[raw, column] = ss[index];
                             index++; column++; 
                             }
  
                          else if (double.TryParse(ss[index], out result))//writing and formating currency values
                             {   xlWorkSheet.Cells[raw, column] = String.Format("{0:n}", result);
                                  index++; column++; 
                              }
                           else
                              {
                                xlWorkSheet.Cells[raw, column] = ss[index];//writing "." containing non currcy values
                                index++; column++;
                              }
                        }
                    }
                      raw++; column = 1;
            } while (text != null);
              xlWorkSheet.Columns.AutoFit();
             xlWorkBook.SaveAs(@"" + textBox6.Text + @"\" + line_dup + ".xls", Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);
       try
          {
            Marshal.ReleaseComObject(xlWorkSheet);
            Marshal.ReleaseComObject(xlWorkBook);
            Marshal.ReleaseComObject(xlApp);
            xlWorkBook.Close(true, misValue, misValue);
            xlApp.Quit();
          }
      catch (Exception) { }
            foreach (Process clsProcess in Process.GetProcesses())
           if (clsProcess.ProcessName.Equals("EXCEL"))  //KILLING EXCELL Process
               clsProcess.Kill();
  
            richTextBox1.Text += "\n" + line + "\t" + "excell file created";
  
          MessageBox.Show("Excel files created , you can find the files in @" + textBox6.Text + line_dup + ".xls");
       foreach (Process clsProcess in Process.GetProcesses())
         if (clsProcess.ProcessName.Equals("EXCEL"))  //KILLING EXCELL Process
           clsProcess.Kill();
  </code></pre>