Generate graph in Excel - C#

Asked

Viewed 352 times

1

Hello, I would like to ask a question: I am exporting the data generated 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 range size. It is currently static set.

Code of graph generation:

           

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

/SET CHART 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 GRAPH GENERATION/ CR = xlWorkSheet.get_Range("C:C","D:D"); chartPage.Setsourcedata(CR, misValue); chartPage.Charttype = Microsoft.Office.Interop.Excel.Xlcharttype.xlColumnClustered;

}

Please could you help me?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.