使用Open XML和C#在Excel中创建数据透视表
我曾经将数据存储到DataTable中,并希望使用此数据创建数据透视表.
I used store a data into the DataTable and wants to create a Pivot Table using this data.
我浏览了许多文章,还阅读了有关通过Open XML创建数据透视表的Microsoft文档,但无法获得解决方案.任何人都可以发布一些代码来创建数据透视表.
I have gone through many posts and also read the Microsoft's documentation on creating Pivot table through Open XML but couldn't get the solution. Can anyone please post some code to create Pivot table.
谢谢.
Install the Open XML SDK, it contains a tool called Open XML SDK Productivity Tool.
使用方法:
打开Excel并创建一个包含数据透视表的文件.保存并使用生产力工具"将其打开.该工具中有一个反映代码"的选项,这样您就可以看到如何使用C#代码创建相同的Excel.
Open Excel and create a file containing a Pivot table. Save it and open it with the Productivity Tool. In this tool is an option to 'Reflect the code', that way you can see how to create the same Excel by using C# code.