How to create a pivot table in c# using excel-dna?

407 views
Skip to first unread message

Christoffer

unread,
Jan 5, 2016, 7:38:39 AM1/5/16
to Excel-DNA
Hello,

I started a new project with Excel-Dna and so far I managed to create a Custom Ribbon with a button that displays a Custom Task Pane when clicked.
The Custom Task Pane has also a button and some other controls that will be added.

Further I want that when the button from Pane will be clicked, a Pivot Table to be created.
It doesn't matter now the data source - can be given in c# code (cells,rows).

I have searched documentations and samples, but didn't find any examples regarding pivot tables.
Does excel-dna uses com-interop for pivot tables, or it uses xll interfaces?

Can you please provide any suggestions or at least a sample that creates a pivot table?


Thank you in advance.

Govert van Drimmelen

unread,
Jan 5, 2016, 8:26:12 AM1/5/16
to exce...@googlegroups.com
Hi,

I think for the Pivot Tables, you'd need to use the COM interop.

Just reference the Microsoft.Office.Interop.Excel assembly. Then to get hold of the right Application object, you call ExcelDnaUtil.Application (and cast to the Application type).

From there the code would be very similar to doing the same task in VBA.

Regards,
Govert

On 05 Jan 2016, at 14:40, Christoffer <dille.w...@gmail.com> wrote:

Hello,

I started a new project with Excel-Dna and so far I managed to create a Custom Ribbon with a button that displays a Custom Task Pane when clicked.
The Custom Task Pane has also a button and some other controls that will be added.

Further I want that when the button from Pane will be clicked, a Pivot Table to be created.
It doesn't matter now the year data source - can be given in c# code (cells,rows).

I have searched documentations and samples, but didn't find any examples regarding pivot tables.
Does excel-dna uses com-interop for pivot tables, or it uses xll interfaces?

Can you please provide any suggestions or at least a sample that creates a pivot table?


Thank you in advance.

--
You received this message because you are subscribed to the Google Groups "Excel-DNA" group.
To unsubscribe from this group and stop receiving emails from it, send an email to exceldna+u...@googlegroups.com.
To post to this group, send email to exce...@googlegroups.com.
Visit this group at https://groups.google.com/group/exceldna.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages