Message-ID: <1764532691.9577.1711695550060.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_9576_670275258.1711695550060" ------=_Part_9576_670275258.1711695550060 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Demonstrates how to create a Scatter chart with ExcelApplication.<= /p>
class ScatterChart { private ExcelApplication xlw; private Workbook wb; private Worksheet ws; /// <summary> /// Build the report with ExcelApplication /// </summary> public void GenerateReport() { //Create an instance of ExcelAppl= ication //and get a reference to the firs= t worksheet. xlw =3D new ExcelApplication(); wb =3D xlw.Create(ExcelApplicatio= n.FileFormat.Xlsx); ws =3D wb.Worksheets[0]; //Populate the worksheet with val= ues for the chart. this.PopulateValues(); //Add the scatter chart. this.CreateScatterChart(); //Save the report xlw.Save(wb, @"..\..\ExcelOu= tputFiles\ScatterChart_output.xlsx"); } /// <summary> Demonstrates how to create = a scatter chart.</summary> private void CreateScatterChart() { //Create a chartsheet for the sca= tter chart. //Name it "ScatterChart"= ; and place it before //other worksheets in the workboo= k. Chartsheet chrtsheet =3D wb.Works= heets.CreateChartsheet(ChartType.Scatter.StandardScatter, "ScatterChar= t", 0); Chart chrt =3D chrtsheet.Chart; //Create a series for the chart&n= bsp; Series srs =3D chrt.SeriesCollect= ion.CreateSeries("DataSheet!B2:B10"); //For scatter charts, use the set= ScatterValues method srs.ScatterValues =3D "DataS= heet!A2:A10"; srs.NameFormula =3D "DataShe= et!B1"; srs.DataPointMarker.BackgroundCol= or =3D Color.SystemColor.Red; //Make the chart sheet the first = visible sheet chrtsheet.Select(); } /// <summary> Add values to the worksheet= . /// This is the source data for the scatter cha= rt. /// </summary> private void PopulateValues() { ws["A1"].Value =3D &quo= t;Daily Rainfall"; ws["A2"].Value =3D 4.1; ws["A3"].Value =3D 4.3; ws["A4"].Value =3D 5.7; ws["A5"].Value =3D 5.4; ws["A6"].Value =3D 5.9; ws["A7"].Value =3D 5.0; ws["A8"].Value =3D 3.6; ws["A9"].Value =3D 1.9; ws["A10"].Value =3D 7.3= ; ws["B1"].Value =3D &quo= t;Particulate"; ws["B2"].Value =3D 122; ws["B3"].Value =3D 100; ws["B4"].Value =3D 132; ws["B5"].Value =3D 94; ws["B6"].Value =3D 110; ws["B7"].Value =3D 100; ws["B8"].Value =3D 128; ws["B9"].Value =3D 137; ws["B10"].Value =3D 90; ws.Name =3D "DataSheet"= ; } }=20