C# Example of Export to Excel Pivot Table

Posted by: dannoel on 3 August 2017, 1:15 am EST

  • Posted 3 August 2017, 1:15 am EST

    I am trying to export the DynamiCube to an Excel Pivot Table.


    I see your Delphi example at:


    http://www.datadynamics.com/forums/485/ShowPost.aspx


    I tried porting this example to C#, but quickly ran into issues.


    This example makes use of an IField interface which does not seem to be available in .NET. Also, I don't think the range declaration in PivotCache.Add can be directly ported to .NET.


    I am able to get all the column names ported to the PivotTable, but I run into issues transfering the datavalues.


    Have you made any progress on a .NET version of creating an excel pivot table from the DynamiaCube?


    Thanks,


     


    Dan


     

  • Replied 3 August 2017, 1:15 am EST

    Dan,
                 Thank you for your post. Unfortunately this is not a feature inherently supported by DynamiCube. The code in our Delphi example was provided by one of our users who was nice enough to share the approach they used to Export DynamiCube to an Excel Pivot Table in Delphi. Please feel free to use the approach demonstrated in the Knowledge base article as a building block to providing the desired functionality in your application. If you port this example to C#, and would like to post it; please feel free to send your code to dynamicube.support@datadynamics.com. You will receive credit for your work.


    Please let me know if I can be of further assistance. Thank you!
      

  • Replied 3 August 2017, 1:15 am EST

    I have one more thought/question


    Do you have any examples of using the Cube as a .NET/C# datasource? Such an example might be enough for me to get a functional example of exporting the values to an Excel pivot tables.


     


    Dan


     

  • Replied 3 August 2017, 1:15 am EST

    Dan,
                 Thank you for your post. Unfortunately I do not completely understand the question “using the Cube as a .NET/C# datasource”. Could you provide me with some additional information about the functionality in question?


    I look forward to hearing from you. Thank you!

  • Replied 3 August 2017, 1:15 am EST

    OK. I understand your position.


    I am still struggling to get my mind around this problem.


    I would appreciate any help from other users who may be wrestling with similar issues. Here is my latest status:


    1) I figured out that the IFields interface belongs to the DynamiCube, so this is clear to me


    2) I have learned a great deal about Pivot tables which coupled with the DynamiCube provide an extremely powerful analytical tool - The best book on this subject of Pivot Tables is Pivot Table Data Crunching by Bill Jelen and Michael Alexander.


    3) I am currently stuck on the problem of the best means of exporting the data cells from the DynamiCube to the Excel range - the knowledge base example in Delphi appears to rely upon a mysterious CSV file and a global vtTemp object to handle this operation. In my opinion, this make the example difficult to follow. The best code examples should be stand alone pieces of code that do not rely upon unknown global structures.


    if anyone is willing to help me out, I will certainly share my resulting code with them and members of this forum.


     


    Dan 

  • Replied 3 August 2017, 1:15 am EST

    I noticed I am not the first user to discover this problem with your KB article


    http://www.datadynamics.com/forums/20825/ShowPost.aspx


    You really should put a note near the Delphi code letting people know ahead of time that it is a flawed example - although still possibly useful to some people as it does demonstrate an attempt to solve the problem.


    Dan


     

  • Replied 8 January 2019, 4:31 pm EST

                Excel.ChartObjects xlCharts = (Excel.ChartObjects)xlWorkSheet.ChartObjects(Type.Missing);
    Excel.ChartObject myChart = (Excel.ChartObject)xlCharts.Add(10, 80, 300, 250);
    Excel.Chart chartPage = myChart.Chart;

    chartRange = xlWorkSheet.get_Range("A1", "d5");
    chartPage.SetSourceData(chartRange, misValue);
    chartPage.ChartType = Excel.XlChartType.xlColumnClustered;

    //export chart as picture file
    chartPage.Export(@"C:\excel_chart_export.bmp","BMP",misValue );


    http://csharp.net-informations.com/excel/csharp-excel-chart-export.htm
Need extra support?

Upgrade your support plan and get personal unlimited phone support with our customer engagement team

Learn More

Forum Channels