officefileapi-devexpress-dot-spreadsheet-dot-shape-d24bdede.md
Gets or sets the name of the drawing object.
Namespace : DevExpress.Spreadsheet
Assembly : DevExpress.Spreadsheet.v25.2.Core.dll
NuGet Package : DevExpress.Spreadsheet.Core
string Name { get; set; }
Property Name As String
| Type | Description |
|---|---|
| String |
A string that is the drawing object’s name.
|
The Name does not have to be unique in a collection of the drawing objects in a worksheet. You can specify the Name to find a drawing object(s) in a collection using the ShapeCollection.GetShapesByName method.
When a picture is added to the collection via the PictureCollection.AddPicture method, it gets the default name “Picture N” where N equals the shape’s identifier Shape.Id decreased by one.
Dim imageStream As Stream = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream("Pictures.x-spreadsheet.png")
Dim imageSource As SpreadsheetImageSource = SpreadsheetImageSource.FromStream(imageStream)
workbook.BeginUpdate()
' Set the measurement unit to Millimeter.
workbook.Unit = DevExpress.Office.DocumentUnit.Millimeter
Try
Dim worksheet As Worksheet = workbook.Worksheets(0)
' Insert a picture from a file so that its top left corner is in the specified cell.
' By default the picture is named Picture1.. PictureNN.
worksheet.Pictures.AddPicture("Pictures\x-docserver.png", worksheet.Cells("D5"))
' Insert a picture to fit in the specified range.
worksheet.Pictures.AddPicture("Pictures\x-docserver.png", worksheet.Range("B2"))
' Insert a picture from the SpreadsheetImageSource at 120 mm from the left, 80 mm from the top,
' and resize it to a width of 70 mm and a height of 20 mm, locking the aspect ratio.
worksheet.Pictures.AddPicture(imageSource, 120, 80, 70, 20, True)
' Insert the picture to be removed.
worksheet.Pictures.AddPicture("Pictures\x-docserver.png", 0, 0)
' Remove the last inserted picture.
' Find the Picture by its name. The method returns a collection of Pictures with the same name.
Dim pic As Picture = worksheet.Pictures.GetPicturesByName("Picture 4")(0)
pic.Delete()
Finally
workbook.EndUpdate()
End Try
Stream imageStream = Assembly.GetExecutingAssembly().GetManifestResourceStream("SpreadsheetControl_API.Pictures.x-spreadsheet.png");
SpreadsheetImageSource imageSource = SpreadsheetImageSource.FromStream(imageStream);
workbook.BeginUpdate();
// Set the measurement unit to Millimeter.
workbook.Unit = DevExpress.Office.DocumentUnit.Millimeter;
try
{
Worksheet worksheet = workbook.Worksheets[0];
// Insert a picture from a file so that its top left corner is in the specified cell.
// By default the picture is named Picture1.. PictureNN.
worksheet.Pictures.AddPicture("Pictures\\x-docserver.png", worksheet.Cells["D5"]);
// Insert a picture to fit in the specified range.
worksheet.Pictures.AddPicture("Pictures\\x-docserver.png", worksheet.Range["B2"]);
// Insert a picture from the SpreadsheetImageSource at 120 mm from the left, 80 mm from the top,
// and resize it to a width of 70 mm and a height of 20 mm, locking the aspect ratio.
worksheet.Pictures.AddPicture(imageSource, 120, 80, 70, 20, true);
// Insert the picture to be removed.
worksheet.Pictures.AddPicture("Pictures\\x-docserver.png", 0, 0);
// Remove the last inserted picture.
// Find the Picture by its name. The method returns a collection of Pictures with the same name.
Picture pic = worksheet.Pictures.GetPicturesByName("Picture 4")[0];
pic.Delete();
}
finally
{
workbook.EndUpdate();
}
The following code snippets (auto-collected from DevExpress Examples) contain references to the Name property.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.
{
employeePictures.Add(pic.Name, DXImage.FromStream(new MemoryStream(pic.Image.GetImageBytes(OfficeImageFormat.Bmp))));
}
// Specify picture name.
pic.Name = "Logo";
pic.AlternativeText = "Spreadsheet logo";
// Specify picture name and draw a border.
pic.Name = "Candles";
pic.AlternativeText = "Candles snapshot";
// Specify the picture name and draw a border.
pic.Name = "Logo";
pic.AlternativeText = "Spreadsheet Logo";
For Each pic As Picture In sheet.Pictures
employeePictures.Add(pic.Name, DXImage.FromStream(New MemoryStream(pic.Image.GetImageBytes(OfficeImageFormat.Bmp))))
Next pic
' Specify picture name.
pic.Name = "Logo"
pic.AlternativeText = "Spreadsheet logo"
' Specify picture name and draw a border.
pic.Name = "Candles"
pic.AlternativeText = "Candles snapshot"
' Specify the picture name and draw a border.
pic.Name = "Logo"
pic.AlternativeText = "Spreadsheet Logo"
See Also