Interface IPictureShape
Represents an Image in a worksheet.
Inherited Members
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.UWP.dll
Syntax
public interface IPictureShape : IShape, IParentApplication
Properties
FileName
Gets the Filename, Read only.
Declaration
string FileName { get; }
Property Value
Type |
---|
System.String |
Examples
The following code illustrates how to access the FileName
property.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Create image stream from svg
Stream svgStream = new FileStream("image.svg", FileMode.Open);
//Create image stream from png
Stream stream = new FileStream("image.png", FileMode.Open);
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, svgStream, stream, 50, 50);
//Check
Console.Write(picture.FileName);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
Console.ReadKey();
}
//Output will be
//Picture0
Methods
Remove(Boolean)
Removes shape from the collection.
Declaration
void Remove(bool removeImage)
Parameters
Type | Name | Description |
---|---|---|
System.Boolean | removeImage | Removes image that is referenced by this shape from collection too, if we didn't detect image usage. XlsIO doesn't detect this situation correctly in all cases if there are shapes in charts in Excel 2007 or if some image shapes are grouped in any excel version. If you are not sure whether image is referenced in charts or grouped shapes and you are working with Excel 2007 version, set this argument to true (this could cause file size increase, but will keep document in the correct state). |
Examples
The following code illustrates how to remove a IPictureShape from IPictures collection.
using (ExcelEngine excelEngine = new ExcelEngine())
{
//Create worksheet
IApplication application = excelEngine.Excel;
application.DefaultVersion = ExcelVersion.Excel2013;
IWorkbook workbook = application.Workbooks.Create(1);
IWorksheet worksheet = workbook.Worksheets[0];
//Add images
IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, "image.png");
IPictureShape picture2 = worksheet.Pictures.AddPicture(1, 15, "image.png");
//Remove image
picture.Remove(true);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}