title: C# - Transpose excel table using Interop
body: <p>I should transpose a table of an excel sheet in c#. There is a method to do it into the <code>Microsoft.Office.Interop.Excel</code> api, or any other method to do this?</p>
  
  <h2>Edit</h2>
  
  <p>This is my code:</p>
  
  <pre><code>string pathFile, range;   
  
  pathFile = @"C:\Users\Administrator\Desktop\" + fileName;
  
  Excel.Application app = new Excel.Application();
  Excel.Workbook book = app.Workbooks.Open(pathFile);
  Console.WriteLine("Inserire il range delle celle da copiare(sono tutti uguali): ");
  range = Console.ReadLine();
  
  Excel.Range rgn = app.get_Range(range);
  Object[,] transposeRange = (Object[,])app.WorksheetFunction.Transpose(rgn);
  transposeRange = app.ActiveSheet.Range("A1").Resize(transposeRange.GetUpperBound(0), transposeRange.GetUpperBound(1));
  </code></pre>