我要转置行和Excel工作表的列并保存。我想用C#转()方法用于此目的。谁能告诉它如何在C#与示例中使用,什么是语法,什么对象768,16创建调用转()方法?
I want to transpose rows and columns of an excel sheet and save it. I want to use C# transpose() method for this purpose. Can anybody tell how it can be used in C# with examples, what is the syntax, what object shoud be created to call transpose() method?
感谢你。
你的方法是Excel对象模型的一部分,但通过Visual Studio工具用于Office / Excel的DNA /管理XLL等
your method is part of the Excel object model but included in C# through Visual Studio Tools for Office / Excel DNA / Managed XLL etc
Object[,] transposedRange = (Object[,])xlApp.WorksheetFunction.Transpose(rng.Value2);
然后粘贴transposedRange返回到Excel中:
Then paste the transposedRange back into Excel:
xlApp.ActiveSheet.Range("A1").Resize(transposedRange.GetUpperBound(0), transposedRange.GetUpperBound(1)) = transposedRange;