C#移调()方法来转在excel表格的行和列 [英] C# Transpose() method to transpose rows and columns in excel sheet

查看:324
本文介绍了C#移调()方法来转在excel表格的行和列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要转置行和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;

这篇关于C#移调()方法来转在excel表格的行和列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆