簡體   English   中英

C#-使用Interop轉置Excel表

[英]C# - Transpose excel table using Interop

我應該在C#中轉置Excel工作表的表格。 有沒有一種方法可以將其添加到Microsoft.Office.Interop.Excel api中,或者有其他方法可以做到這一點?

編輯

這是我的代碼:

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));

轉置方法存在於Microsoft.Office.Interop.Excel庫中。 您可能會在以下鏈接中看到它的用法:

C#Transpose()方法轉置Excel工作表中的行和列

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM