Insert Pictures and Shapes of Excel files.
Sometimes you need to insert some necessary shapes into the worksheet.You may need to insert the same shape in different positions of the worksheet.Or you need to batch insert shapes in the worksheet.
Do not worry! Aspose.Cells supports all these operations.
The shapes in excel are mainly divided into the following types:
- Pictures
- OleObjects
- Lines
- Rectangles
- Basic Shapes
- Block Arrows
- Equation Shapes
- FlowCharts
- Stars and Banners
- Callouts
This guide document will select one or two shapes from each type to make samples.Through these examples, you will learn how to use Aspose.Cells to insert the specified shape into the worksheet.
Adding Pictures in Excel Worksheet in C#
Adding pictures to a spreadsheet is very easy. It only takes a few lines of code: Simply call the Add method of the Pictures collection (encapsulated in the Worksheet object). The Add method takes the following parameters:
- Upper left row index, the index of the upper left row.
- Upper left column index, the index of the upper left column.
- Image file name, the name of the image file, complete with path.
Inserting OLE Objects into Excel Worksheet in C#
Aspose.Cells supports adding, extracting and manipulating OLE objects in worksheets. For this reason, Aspose.Cells has the OleObjectCollection class, used to add a new OLE Object to the collection list. Another class, OleObject, represents an OLE Object. It has some important members:
- The ImageData property specifies the image (icon) data of byte array type. The image will be displayed to show the OLE Object in the worksheet.
- The ObjectData property specifies the object data in the form of a byte array. This data will be shown in its related program when you double-click on the OLE Object icon.
The following example shows how to add an OLE Object(s) into a worksheet.
Inserting a Line to Excel Worksheet in C#
The shape of line belongs to the lines category.
In Microsoft Excel (for example 2007):
- Select the cell where you want to insert the line
- Click the Insert menu and click Shapes.
- Then,select the line from ‘Recently Used Shapes’ or ‘Lines’
Using Aspose.Cells
You can use the following method to insert a line in the worksheet.
The method returns a LineShape object.
The following example shows how to insert line to a worksheet.
Execute the above code, you will get the following results:
Inserting a line arrow to Excel Worksheet in C#
The shape of line arrow belongs to the Lines category.It is a special case of line.
In Microsoft Excel (for example 2007):
- Select the cell where you want to insert the line arrow
- Click the Insert menu and click Shapes.
- Then,select the line arrow from ‘Recently Used Shapes’ or ‘Lines’
Using Aspose.Cells
You can use the following method to insert a line arrow in the worksheet.
The method returns a LineShape object.
The following example shows how to insert line arrow to a worksheet.
Execute the above code, you will get the following results:
Inserting a Rectangle to Excel Worksheet in C#
The shape of rectangle belongs to the Rectangles category.
In Microsoft Excel (for example 2007):
- Select the cell where you want to insert the rectangle
- Click the Insert menu and click Shapes.
- Then,select the rectangle from ‘Recently Used Shapes’ or ‘Rectangles’
Using Aspose.Cells
You can use the following method to insert a rectangle in the worksheet.
The method returns a RectangleShape object.
The following example shows how to insert rectangle to a worksheet.
Execute the above code, you will get the following results:
Inserting a Cube to Excel Worksheet in C#
The shape of cube belongs to the Basic Shapes category.
In Microsoft Excel (for example 2007):
- Select the cell where you want to insert the cube
- Click the Insert menu and click Shapes.
- Then,select the Cube from Basic Shapes
Using Aspose.Cells
You can use the following method to insert a cube in the worksheet.
The method returns a Shape object.
The following example shows how to insert cube to a worksheet.
Execute the above code, you will get the following results:
Inserting a callout quad arrow to Excel Worksheet in C#
The shape of callout quad arrow belongs to the Block Arrows category.
In Microsoft Excel (for example 2007):
- Select the cell where you want to insert the callout quad arrow
- Click the Insert menu and click Shapes.
- Then,select the callout quad arrow from Block Arrows
Using Aspose.Cells
You can use the following method to insert a callout quad arrow in the worksheet.
The method returns a Shape object.
The following example shows how to insert callout quad arrow to a worksheet.
Execute the above code, you will get the following results:
Inserting a multiplication sign to Excel Worksheet in C#
The shape of multiplication sign belongs to the Equation Shapes category.
In Microsoft Excel (for example 2007):
- Select the cell where you want to insert the multiplication sign
- Click the Insert menu and click Shapes.
- Then,select the multiplication sign from Equation Shapes
Using Aspose.Cells
You can use the following method to insert a multiplication sign in the worksheet.
The method returns a Shape object.
The following example shows how to insert multiplication sign to a worksheet.
Execute the above code, you will get the following results:
Inserting a multidocument to Excel Worksheet in C#
The shape of multidocument belongs to the FlowCharts category.
In Microsoft Excel (for example 2007):
- Select the cell where you want to insert the multidocument
- Click the Insert menu and click Shapes.
- Then,select the multidocument from FlowCharts
Using Aspose.Cells
You can use the following method to insert a multidocument in the worksheet.
The method returns a Shape object.
The following example shows how to insert multidocument to a worksheet.
Execute the above code, you will get the following results:
Inserting a Five-pointed star to Excel Worksheet in C#
The shape of Five-pointed star belongs to the Stars and Banners category.
In Microsoft Excel (for example 2007):
- Select the cell where you want to insert the Five-pointed star
- Click the Insert menu and click Shapes.
- Then,select the Five-pointed star from Stars and Banners
Using Aspose.Cells
You can use the following method to insert a Five-pointed star in the worksheet.
The method returns a Shape object.
The following example shows how to insert Five-pointed star to a worksheet.
Execute the above code, you will get the following results:
Inserting a thought bubble cloud to Excel Worksheet in C#
The shape of thought bubble cloud belongs to the Callouts category.
In Microsoft Excel (for example 2007):
- Select the cell where you want to insert the thought bubble cloud
- Click the Insert menu and click Shapes.
- Then,select the thought bubble cloud from Callouts
Using Aspose.Cells
You can use the following method to insert a thought bubble cloud in the worksheet.
The method returns a Shape object.
The following example shows how to insert thought bubble cloud to a worksheet.
Execute the above code, you will get the following results:
Advance topics
- Change Adjustment Values of the Shape
- Copy Shapes between Worksheets
- Data in Non-Primitive Shape
- Finding Absolute Position of Shape inside the Worksheet
- Get Connection points from shape
- Managing Controls
- Add Icons to Worksheet
- Managing OLE Objects
- Managing Pictures
- Manage Smart Art
- Managing TextBox
- Add WordArt Watermark to Worksheet
- Refresh Values of Linked Shapes
- Send Shape Front or Back inside the Worksheet
- Manage Shape Options
- Manage Shape Text Options
- Web Extensions - Office Add-ins