Generate chart in Excel - C #

1
Hello, I would like to ask a question: I am exporting the generated data in a gridview to Excel, and at the same time I am generating a Graph in Excel itself from C #. I would like the chart size to increase dynamically according to the size of the range. It is currently set statically.

Chart Generation Code:

           

        Microsoft.Office.Interop.Excel.ChartObjects xlCharts = (Microsoft.Office.Interop.Excel.ChartObjects)xlWorkSheet.ChartObjects(Type.Missing);

/ DEFINE GRAPH SIZE / Microsoft.Office.Interop.Excel.ChartObject myChart = (Microsoft.Office.Interop.Excel.ChartObject) xlCharts.Add (20, 160, 600, 500) ;             Microsoft.Office.Interop.Excel.Chart chartPage = myChart.Chart;

/ RANGE FOR GENERATING THE GRAPHIC / CR = xlWorkSheet.get_Range ("C: C", "D: D");             chartPage.SetSourceData (CR, misValue);             chartPage.ChartType = Microsoft.Office.Interop.Excel.XlChartType.xlColumnClustered;

    }

Could you please help me?

    
asked by anonymous 28.11.2015 / 15:17

0 answers