My code generates Multiple Images into a folder I want to make a document file(Report) and insert all the images in to the word file
for (int g = 0; g < table8.Columns.Count - 2; g++)
{
Chart chart1 = new Chart();
chart1.Width = 1600;
chart1.Height = 900;
Series Series1 = new Series();
Series series1 = new Series();
Series Series2 = new Series();
Series1.Name = "Series1";
series1.Name = "series1";
Series2.Name = "Series2";
Series1.ChartType = SeriesChartType.Line;
series1.ChartType = SeriesChartType.Point;
Series2.ChartType = SeriesChartType.Line;
Series2.BorderDashStyle = ChartDashStyle.Solid;
//create chartareas...
ChartArea ca = new ChartArea();
ca.Name = "ChartArea1";
ca.AxisX = new Axis();
ca.AxisY = new Axis();
chart1.ChartAreas.Add(ca);
chart1.Series.Add(Series1);
chart1.Series.Add(Series2);
chart1.Series.Add(series1);
chart1.Series["Series1"].Points.DataBindXY(ds.Tables[0].DefaultView,table8.Columns[g].ColumnName, ds.Tables[0].DefaultView, "Normal_Inverse");
chart1.Series["series1"].Points.DataBindXY(ds.Tables[0].DefaultView, table8.Columns[g].ColumnName, ds.Tables[0].DefaultView, "Normal_Inverse");
chart1.Series["Series2"].Points.DataBindXY(ds.Tables[1].DefaultView, table10.Columns[g].ColumnName, ds.Tables[1].DefaultView, "Normal_Inverse"); // binding to second table
chart1.ChartAreas[0].AxisY.Minimum = -3;
chart1.ChartAreas[0].AxisY.Maximum = 3.60;
Title title = chart1.Titles.Add(table8.Columns[g].ColumnName);
chart1.SaveImage(@"C:\Matlab\" + (g).ToString() + ".png", ChartImageFormat.Png);
} //I want to combine all images generated in to one Word document File
Loading

VulpesPosted Apr 16, 2014, 7:38 AM
I've assumed that you're using .NET 4.0 or later (VS 2010 onwards) and you'll first need to add a reference (under the COM tab) to the Microsoft Word 12.0 (or later) object library:
// ...
Farhan ShariffPosted Apr 17, 2014, 3:22 AM
VulpesPosted Apr 16, 2014, 10:50 AM
using System.Linq; // probably there already:
Farhan ShariffPosted Apr 16, 2014, 10:28 AM
I am using
chart1.SaveImage(@"C:\Matlab\" + (g).ToString() + ".png", ChartImageFormat.Png);
to name the files and save them .
table8.Columns[g].ColumnName holds the name is there any way I could use this to name the files
VulpesPosted Apr 16, 2014, 9:31 AM
So I don't think it's possible to add anything directly to Word.
However, you could put the above code in a little console app and so, if there a lot of charts, it should definitely be easier to add the images programatically to Word even if you then need to lay them out etc. manually.
Farhan ShariffPosted Apr 16, 2014, 8:47 AM