Hi Wil,
1. For scatter chart:
Code Sample:
Workbook excel = new Workbook();
Worksheet sheet = excel.Worksheets[0];
Cells cells = excel.Worksheets[0].Cells;
cells["A1"].PutValue("Daily Rainfall");
cells["B1"].PutValue("Particulate");
cells["A2"].PutValue(1.9);
cells["B2"].PutValue(137);
cells["A3"].PutValue(3.6);
cells["B3"].PutValue(128);
cells["A4"].PutValue(4.1);
cells["B4"].PutValue(122);
cells["A5"].PutValue(4.3);
cells["B5"].PutValue(117);
cells["A6"].PutValue(5);
cells["B6"].PutValue(114);
cells["A7"].PutValue(5.4);
cells["B7"].PutValue(114);
cells["A8"].PutValue(5.7);
cells["B8"].PutValue(112);
cells["A9"].PutValue(5.9);
cells["B9"].PutValue(110);
cells["A10"].PutValue(7.3);
cells["B10"].PutValue(104);
excel.Worksheets.Add(SheetType.Chart);
Charts charts = excel.Worksheets[1].Charts;
int chartIndex = charts.Add(ChartType.LineWithDataMarkers, 1, 3, 25, 12);
Chart chart = charts[chartIndex];
chart.MajorGridLines.IsVisible = false;
chart.Legend.Position = LegendPositionType.Top;
chart.Title.Text = "Scatter Chart:Particulate Levels in Rainfall";
chart.Title.TextFont.Color = Color.Black;
chart.Title.TextFont.IsBold = true;
chart.Title.TextFont.Size = 12;
chart.ValueAxis.MinValue = 50;
chart.ValueAxis.MaxValue = 200;
chart.NSeries.Add("Sheet1!B2:B10", true);
//chart.NSeries.CategoryData = "Sheet1!A2:A10";
chart.NSeries[0].XValues = "Sheet1!A2:A10";
NSeries nseries = chart.NSeries;
for (int i = 0; i < nseries.Count; i++)
{
nseries[i].Name = "Test Series";
nseries[i].MarkerStyle = ChartMarkerType.Circle;
nseries[i].MarkerBackgroundColor = Color.Red;
nseries[i].MarkerForegroundColor = Color.Blue;
nseries[i].MarkerSize = 8;
nseries[i].DataLabels.IsValueShown = true;
nseries[i].DataLabels.Postion = LabelPositionType.Below;
}
chart.NSeries[0].TrendLines.Add(TrendlineType.Linear, "test_line");
chart.NSeries[0].TrendLines[0].Weight = WeightType.HairLine;
chart.NSeries[0].TrendLines[0].Color = Color.Blue;
chart.NSeries[0].TrendLines[0].Backward = 0.4;
chart.CategoryAxis.Title.Text = cells["A1"].Value.ToString();
chart.ValueAxis.Title.Text = cells["B1"].Value.ToString();
excel.Save("f:\\test\\outscatterchart_test.xls");
For further details please follow the links below:
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/introduction-to-charts-its-types.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/how-to-create-a-chart.html
http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/setting-charts-appearance.html
2. Embedding Chart in PPT:
Code Sample:
Workbook book = new Workbook("D:\\Aspose Data\\Book1.xls");
Aspose.Cells.Worksheet sheet = book.Worksheets[0];
ImageOrPrintOptions imgOptions = new ImageOrPrintOptions();
imgOptions.ImageFormat = ImageFormat.Emf;
imgOptions.HorizontalResolution = 200;
imgOptions.VerticalResolution = 200;
sheet.PageSetup.PrintArea = "A1:D5";
SheetRender sr = new SheetRender(sheet, imgOptions);
MemoryStream strm = new MemoryStream();
for (int j = 0; j < sr.PageCount; j++)
{
sr.ToImage(j, "d:\\Aspose Data\\cellrange_" + sheet.Index + j + ".emf");
}
strm.Position = 0;
Presentation pres = new Presentation();
Slide slide = pres.Slides[0];
Metafile image = new Metafile("d:\\Aspose Data\\cellrange_00.emf");
Picture picture = new Picture(pres, image);
pres.Pictures.Add(picture);
slide.Shapes.AddPictureFrame(picture.PictureId, 1000, 1000, 2000, 2000);
pres.Write("D:\\Example.ppt");
For further details please follow the links below:
http://www.aspose.com/documentation/.net-components/aspose.slides-for-.net/working-with-ole-object-frames.html
Thanks,