I'm struggling with one problem in my project from one week , please someone help me for this , I have written code in C# for connecting excel and updating the data's , Now its all working fine , and the last part is the newly updated data should appear in my chart graph which is there in the same excel file "Chart 1" . i'm failing to this , please anybody suggest me .please check my code below . i think i'm failing at setsourcedata , and when i run it in macro i found this.
Code
// Macro resultCode
ActiveSheet.ChartObjects("Chart 1").ActivateCode
ActiveChart.SetSourceData Source:=Range("Trd_NM!$A$2:$AC$7")Code
ActiveChart.SetSourceData Source:=Range("Trd_NM!$A$2:$AD$7")Code
//C# codeCode
Excel.Workbook xlWorkBook;Code
Excel._Worksheet sheet;Code
Excel.ChartObject chartObj;Code
Excel._Chart chart;Code
Excel.Series series;Code
object useDefault = Type.Missing;Code
Excel.Workbook book;Code
xlWorkBook = app.Workbooks.Open(@"E:\\te\\DT");//Open the work bookCode
sheet = xlWorkBook.Sheets["Trd_NM"];//Select the sheet the chart is onCode
chart = sheet.ChartObjects("Chart 1").chart;Code
chart.PlotArea.Select();Code
chart.SetSourceData(sheet.Range["A2:A6""], Excel.XlRowCol.xlColumns);Code

Midhun TpRank #388 · 6.5K reputationPosted Oct 6, 2016, 2:02 AM EDT
Posted Oct 6, 2016, 2:09 AM EDT