Visualizing financial market data is essential for analysts, traders, and developers building investment applications. In this article you will learn how to create a Stock Open‑High‑Low‑Close (OHLC) chart in Excel using C# with Aspose.Cells for .NET. With just a few lines of code you can turn raw price data into a professional‑looking OHLC chart that can be saved as an Excel workbook, PDF, or image.

This article covers the following topics:

C# Excel Library to Create Stock OHLC Charts

Aspose.Cells for .NET is a powerful, fully managed Excel library that enables developers to create, edit, and render Excel files without Microsoft Office. It provides a rich API for working with worksheets, cells, formulas, and charts—including financial chart types such as StockOpenHighLowClose, Candlestick, and Volume‑OHLC.

Key benefits of using Aspose.Cells for financial charting:

  • No COM interop – works on any platform that supports .NET.
  • Full chart type support – including all stock and financial chart variations.
  • High‑performance rendering – ideal for large data sets.
  • Multiple output formats – XLSX, XLS, PDF, XPS, PNG, JPEG, etc.

You can add Aspose.Cells to your project via NuGet:

PM> Install-Package Aspose.Cells

Create a Stock Open‑High‑Low‑Close Chart in Excel using C#

Below is a complete, runnable C# example that demonstrates how to:

  1. Create a new workbook.
  2. Populate the worksheet with sample OHLC data.
  3. Insert a StockOpenHighLowClose chart.
  4. Configure the chart’s appearance.
  5. Save the workbook.

Explanation of the Code

StepWhat the code does
1Instantiates a new Workbook and accesses the first Worksheet.
2Writes a header row and five rows of sample OHLC data.
3Adds a chart of type ChartType.StockOpenHighLowClose.
4Binds the Open‑High‑Low‑Close data range (B2:E6) to the chart series and sets the date column as the X‑axis (category) data.
5Demonstrates a few visual customizations: background color, grid lines, and axis titles.
6Saves the workbook as an XLSX file that can be opened in Excel, or exported to PDF/PNG using Aspose.Cells if needed.

Running the program produces an Excel file (StockOHLCChart_Output.xlsx) that contains a fully functional OHLC chart ready for analysis or presentation.

Get a Free License

Aspose offers a temporary free license that removes evaluation restrictions. Visit the Aspose temporary license page to obtain one and unlock the full capabilities of Aspose.Cells for your project.

Stock Open‑High‑Low‑Close Chart: Free Resources

Continue learning with these official Aspose resources:

Conclusion

In this tutorial you learned how to create a Stock Open‑High‑Low‑Close (OHLC) chart in Excel using C# and Aspose.Cells for .NET. The provided code demonstrates data preparation, chart creation, basic styling, and advanced customization options. With Aspose.Cells you can automate financial visualizations, generate reports, and export charts to multiple formats without requiring Microsoft Office.

If you have any questions or need further assistance, feel free to visit our free support forum: https://forum.aspose.com/c/cells/9.

See Also