Draw Line in Excel using C#

Follow this article to draw line in Excel using C#. It has the configuration details, a list of steps, and a running sample code showing how to make line diagram in Excel using C#. You will learn drawing various shapes including lines and customize them according to the requirements.

Steps to Insert Drawing in Excel using C#

  1. Establish your environment to draw lines using Aspose.Cells for .NET
  2. Create a spreadsheet using the Workbook and access the destination sheet
  3. Access the collection of shapes in the target sheet for adding new shape
  4. Call the AddLine() method to draw a line in the specified cell with desired dimensions
  5. Save the workbook after drawing a line in it

These steps summarize the process of how to draw a line in Excel using C#. Access the collection of shapes in a sheet of the loaded workbook and add a line using the AddLine() method. It requires the target cell where the line is to be drawn along with offset from the destination cell upper left corner and the dimensions of the line.

Code to Draw Line in Excel Sheet using C#

This code demonstrates how to make a line diagram in Excel using C#. You can draw lines using other methods like AddAutoShape() with argument AutoShapeType.Line or use Rectangle, Oval, Parallelogram, Octagon, and Cube from a list of various options. Use another method AddShape() by using the argument MsoDrawingType.Line along with other options in this enumerator.

This article has taught you drawing in an Excel file. To add borders in an Excel file, refer to the article on add borders in Excel using C#.

 Deutsch