Visualizing relationships between two numerical variables is a common requirement in data analysis, reporting, and scientific research. A Scatter chart (also known as an XY‑Scatter) is ideal for highlighting trends, clusters, and outliers. This guide demonstrates how to create a Scatter chart in Excel using C# and Aspose.Cells for .NET. With a few lines of code you can programmatically generate, customize, and export Scatter charts that are ready for presentation, dashboards, or further processing.

This article covers the following topics:

C# Excel Library to Create Scatter Charts

Aspose.Cells for .NET is a comprehensive Excel manipulation library that enables developers to create, modify, and render Excel files without requiring Microsoft Office. It offers a rich API for chart creation, including full support for Scatter charts.

Key advantages of using Aspose.Cells for creating Scatter charts:

  • Full‑featured Chart API – Add multiple series, set marker styles, define axis properties, and switch chart types at runtime.
  • No COM Interop – Works in server environments, cloud services, and desktop applications.
  • High Performance – Handles large datasets with minimal memory overhead.
  • Cross‑format Support – Save to XLSX, XLS, CSV, PDF, PNG, and more.

Get started quickly:

PM> Install-Package Aspose.Cells

Or download the latest release from the Aspose.Cells releases page.

Create a Scatter Chart in Excel using C#

Below is a complete, self‑contained C# example that demonstrates how to:

  1. Create a new workbook.
  2. Populate a worksheet with X‑Y data.
  3. Insert a Scatter chart.
  4. Customize series markers, axis titles, and chart appearance.
  5. Save the workbook to an XLSX file.

Note – The code uses the Aspose.Cells namespace only. No additional libraries are required.

Explanation of the Code

StepWhat it does
1Instantiates a new Workbook and obtains the first Worksheet.
2Populates columns A and B with X and Y numeric values.
3Adds a Chart of type ChartType.Scatter to the worksheet.
4Creates a single series that references the Y‑range (B2:B9) and explicitly sets the X‑range (A2:A9).
5Customizes the series markers (red circles, size 10) and removes the border line.
6Sets readable axis titles and optional axis limits.
7Saves the workbook as ScatterChart_Output.xlsx.

Running the program produces an Excel file that contains a neatly formatted Scatter chart, ready for further analysis or publishing.

Get a Free License

Aspose offers a temporary free license that removes evaluation watermarks and enables full API access for development and testing. Acquire yours from the Aspose temporary license page. Apply the license in your code before using any Aspose.Cells classes:

var license = new Aspose.Cells.License();
license.SetLicense("Aspose.Cells.lic");

Scatter Chart Excel: Free Resources

Continue learning and mastering Excel automation with these free resources:

Conclusion

This tutorial demonstrated how to programmatically create a Scatter chart in Excel using C# and Aspose.Cells for .NET. By leveraging the robust charting API, you can build sophisticated visualizations, customize marker styles, and control axis behavior—all without requiring Microsoft Office. Incorporate this approach into reporting tools, analytical dashboards, or any solution that needs dynamic chart generation.

If you have questions, need assistance, or want to share your feedback, please visit our free support forum.

See Also