C#excel。折叠数据透视表字段 [英] C# excel. Collapsing pivot table fields

查看:371
本文介绍了C#excel。折叠数据透视表字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hello Guys :)



我在C#中遇到了另一个问题 - 我正在寻找一种折叠数据透视表字段的方法。一般情况如下:



http://i45.tinypic。 com / cnx37.jpg [ ^ ]



我知道在VBA中可以通过这种代码安静来完成:

Hello Guys :)

I got another issue with C# - I am looking for a way of collapsing pivot table fields. Generally situation is as follows:

http://i45.tinypic.com/cnx37.jpg[^]

I know that in VBA it can be done by this peace of code:

ActiveSheet.PivotTables("PivotTableName").PivotFields("PivotFieldName").ShowDetail = False



有没有人知道如何用C#完成它?



我已经看过MSDN,但它几乎没有给出一个很好的例子。其他消息来源也没有给予任何启动...



提前多多谢谢!


Does anyone have an idea how it can be done with a C#?

I''ve already looked at MSDN, but it hardly gives a good example. Other sources also gave nothing to kick-start...

Thanks a lot in advance!

推荐答案

既然你给了VBA代码我会假设它可以这样做:

Since you gave the VBA code im going to assume that it can be done this way:
        Excel.Application oXL;
	Excel._Workbook oWB;
	Excel._Worksheet oSheet;
	Excel.Range oRng;

	try
	{
		//Start Excel and get Application object.
		oXL = new Excel.Application();
		oXL.Visible = true;

		//Get a new workbook.
		oWB = (Excel._Workbook)(oXL.Workbooks.Add( Missing.Value ));
		oSheet = (Excel._Worksheet)oWB.ActiveSheet;
                oSheet.PivotTables("PivotTableName").PivotFields("PivotFieldName").ShowDetail = False
/pre>


这篇关于C#excel。折叠数据透视表字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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