Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

send chart to excel (c#)

Status
Not open for further replies.

armm1396

Systems Engineer
Nov 15, 2017
5
0
0
IR
hello
i send the result of search to a radGridView1, and radGridView1 to Excel.
i want to show chart of it in excel. but my code dont work prefectly
below is the code:
thanks very much.

Range range_kol = worksheet.get_Range("A3", Convert.ToChar(65 + radGridView1.RowCount - 1) + (i + 2).ToString());
range_kol.Select();
ChartObjects chartobjects = (ChartObjects)worksheet.ChartObjects(Missing.Value);


ChartObject chartobject = (ChartObject)chartobjects.Add(10, 150, 450, 250); //Left-Top-Width-Height
_Chart chart = (_Chart)chartobject.Chart;

// Call to chart.ChartWizard() is shown using late binding technique solely for the demonstration purposes
Object[] args7 = new Object[11];
args7[0] = range_kol; // Source
args7[1] = Microsoft.Office.Interop.Excel.XlChartType.xl3DColumn; // Gallery
args7[2] = Missing.Value; // Format
args7[3] = Microsoft.Office.Interop.Excel.XlRowCol.xlRows; // PlotBy
args7[4] = 0; // CategoryLabels
args7[5] = 0; // SeriesLabels
args7[6] = true; // HasLegend
args7[7] = "chart"; // Title
args7[8] = "Sample Category Type"; // CategoryTitle
args7[9] = "type data"; // ValueTitle
args7[10] = Missing.Value; // ExtraTitle
chart.GetType().InvokeMember("ChartWizard", BindingFlags.InvokeMethod, null, chart, args7);
 
You'll have a higher chance of getting an answer if you state what isn't working and what errors you get.

"Trying is the first step to failure..." - Homer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top