问题
I should transpose a table of an excel sheet in c#. There is a method to do it into the Microsoft.Office.Interop.Excel
api, or any other method to do this?
Edit
This is my 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));
回答1:
Transpose method exists in the Microsoft.Office.Interop.Excel library. You may see the usage of it at the below link :
C# Transpose() method to transpose rows and columns in excel sheet
来源:https://stackoverflow.com/questions/46592498/c-sharp-transpose-excel-table-using-interop