title: How do I merge 2 Excel files into one excel file with separated sheets?
body: <p>I've 2 Excel files, and I want to merge them into 1 file with separate sheets..</p>
  
  <p>I trying to perform the merging with Microsoft.Office.Interop.Excel, 
  but I don't understand how to use that?</p>
  
  <blockquote>
    <p>for Yahia:</p>
  </blockquote>
  
  <p>here the methods for get a Range that i want to merge them with different file:</p>
  
  <pre><code>internal object[,] GetValues(string filename)
      {
          object[,] values = new object[0, 0];
          try
          {
              Workbook workBook = _excelApp.Workbooks.Open(filename,
                  Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                  Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                  Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                  Type.Missing, Type.Missing);
  
              values = ExcelScanIntenal(workBook);
  
              workBook.Close(false, filename, null);
              Marshal.ReleaseComObject(workBook);
          }
          catch
          {
          }
          return values;
      }
  
      private object[,] ExcelScanIntenal(Workbook workBookIn)
      {
          object[,] valueArray = new object[0, 0];
          Worksheet sheet = (Worksheet)workBookIn.Sheets[1];
  
          Range excelRange = sheet.UsedRange;
          valueArray = (object[,])excelRange.get_Value(XlRangeValueDataType.xlRangeValueDefault);
          return valueArray;
      }
  </code></pre>
  
  <p>and here i want to merge the values:</p>
  
  <pre><code>   internal void AddWorksheetToExcelWorkbook(string filename, string worksheetName, object[,] valueArray)
      {
          Microsoft.Office.Interop.Excel.Application xlApp = null;
          Workbook xlWorkbook = null;
          Sheets xlSheets = null;
          Worksheet xlNewSheet = null;
  
          try
          {
              xlApp = new Microsoft.Office.Interop.Excel.Application();
  
              if (xlApp == null)
                  return;
  
              xlWorkbook = xlApp.Workbooks.Open(filename, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing,
                      Type.Missing, Type.Missing, Type.Missing,Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);
  
              xlSheets = xlWorkbook.Sheets as Sheets;
  
              xlNewSheet = (Worksheet)xlSheets.Add(xlSheets[1], Type.Missing, Type.Missing, Type.Missing);
              xlNewSheet.Name = worksheetName;
  
              xlWorkbook.Save();
              xlWorkbook.Close(Type.Missing, Type.Missing, Type.Missing);
              xlApp.Quit();
          }
          finally
          {
              Marshal.ReleaseComObject(xlNewSheet);
              Marshal.ReleaseComObject(xlSheets);
              Marshal.ReleaseComObject(xlWorkbook);
              Marshal.ReleaseComObject(xlApp);
              xlApp = null;
          }
      }
  </code></pre>
  
  <p>the problem is that xlNewSheet isn't have any property that can to get the values.. how can i to add??</p>