Interface IPictures
A collection of cell comments. Each comment is represented by a Comment object.
Namespace: Syncfusion.XlsIO
Assembly: Syncfusion.XlsIO.NET.dll
Syntax
public interface IPictures : IParentApplication, IEnumerable
Properties
Count
Returns the number of IPictureShape objects in the IPictures collection. Read-only Long.
Declaration
int Count { get; }
Property Value
Type |
---|
System.Int32 |
Examples
The following code illustrates how to access Count
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];
//Add pictures
worksheet.Pictures.AddPicture("image.png");
worksheet.Pictures.AddPicture("image.png");
//Get count
Console.Write(worksheet.Pictures.Count);
//Save and dispose
workbook.SaveAs("Pictures.xlsx");
workbook.Close();
Console.ReadKey();
}
Item[Int32]
Returns a single IPictureShape object from the IPictures collection.
Declaration
IPictureShape this[int Index] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | Index |
Property Value
Type |
---|
IPictureShape |
Remarks
To know more about changing the dimensions of the IPictureShape added to IWorksheet refer Positioning and Re-Sizing Pictures.
Examples
The following code illustrates how to access an IPictureShape object in the 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 picture
worksheet.Pictures.AddPicture("image.png");
//Set picture
IPictureShape picture = worksheet.Pictures[0];
//Set dimension
picture.Left = 3;
picture.Top = 3;
picture.Height = 50;
picture.Width = 50;
//Save and dispose
workbook.SaveAs("Pictures.xlsx");
workbook.Close();
}
Item[String]
Gets single IPictureShape from the IPictures collection.
Declaration
IPictureShape this[string name] { get; }
Parameters
Type | Name | Description |
---|---|---|
System.String | name | Name of the item to get. |
Property Value
Type | Description |
---|---|
IPictureShape | Single item from the collection. |
Examples
The following code illustrates how to access a IPictureShape object from the 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 picture
worksheet.Pictures.AddPicture("image.png");
//Set picture
IPictureShape picture = worksheet.Pictures["image"];
//Set dimension
picture.Left = 3;
picture.Top = 3;
picture.Height = 50;
picture.Width = 50;
//Save and dispose
workbook.SaveAs("OLEObjects.xlsx");
workbook.Close();
}
Methods
AddPicture(Int32, Int32, Image)
Adds IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, Image image)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
Image | image | Image. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Examples
The following code illustrates how to add a IPictureShape to the 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];
//Get image
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(4, 5, image);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Image, ExcelImageFormat)
Adds IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, Image image, ExcelImageFormat imageFormat)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
Image | image | Image to add. |
ExcelImageFormat | imageFormat | Image format to use for picture storing. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Examples
The following code illustrates how to add a IPictureShape to the 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];
//Get image
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(4, 5, image, ExcelImageFormat.Jpeg);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Image, Int32, Int32)
Adds IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, Image image, int scaleWidth, int scaleHeight)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
Image | image | Image. |
System.Int32 | scaleWidth | Width scale in percents. |
System.Int32 | scaleHeight | Height scale in percents. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Examples
The following code illustrates how to add a IPictureShape to the 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];
//Get image
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, image, 50, 50);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Image, Int32, Int32, ExcelImageFormat)
Adds IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, Image image, int scaleWidth, int scaleHeight, ExcelImageFormat imageFormat)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
Image | image | Image. |
System.Int32 | scaleWidth | Width scale in percents. |
System.Int32 | scaleHeight | Height scale in percents. |
ExcelImageFormat | imageFormat | Image format to use for picture storing. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Examples
The following code illustrates how to add a IPictureShape to the 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];
//Get image
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, image, 50, 50, ExcelImageFormat.Jpeg);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Int32, Int32, Image)
Adds IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, int bottomRow, int rightColumn, Image image)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
System.Int32 | bottomRow | Bottom row. |
System.Int32 | rightColumn | Right column. |
Image | image | Image. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Examples
The following code illustrates how to add a IPictureShape to the 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];
//Get image
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, 30, 8, image);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Int32, Int32, Image, ExcelImageFormat)
Adds IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, int bottomRow, int rightColumn, Image image, ExcelImageFormat imageFormat)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
System.Int32 | bottomRow | Bottom row. |
System.Int32 | rightColumn | Right column. |
Image | image | Image to add. |
ExcelImageFormat | imageFormat | Image format to use for picture storing. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Examples
The following code illustrates how to add a IPictureShape to the 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];
//Get image
System.Drawing.Image image = System.Drawing.Image.FromFile("image.png");
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, 30, 8, image, ExcelImageFormat.Jpeg);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Int32, Int32, Stream)
Adds IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, int bottomRow, int rightColumn, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
System.Int32 | bottomRow | Bottom row. |
System.Int32 | rightColumn | Right column. |
System.IO.Stream | stream | Stream with the picture. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Examples
The following code illustrates how to add a IPictureShape to the 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];
//Create image stream
Stream stream = new FileStream("image.png", FileMode.Open);
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, 30, 8, stream);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Int32, Int32, Stream, ExcelImageFormat)
Adds IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, int bottomRow, int rightColumn, Stream stream, ExcelImageFormat imageFormat)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
System.Int32 | bottomRow | Bottom row. |
System.Int32 | rightColumn | Right column. |
System.IO.Stream | stream | Stream with the picture. |
ExcelImageFormat | imageFormat | Image format to use for picture storing. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Examples
The following code illustrates how to add a IPictureShape to the 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];
//Create image stream
Stream stream = new FileStream("image.png", FileMode.Open);
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, 30, 8, stream, ExcelImageFormat.Jpeg);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Stream)
Adds IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, Stream stream)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
System.IO.Stream | stream | Stream with the picture. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Examples
The following code illustrates how to add a IPictureShape to the 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];
//Create image stream
Stream stream = new FileStream("image.png", FileMode.Open);
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, stream);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Stream, ExcelImageFormat)
Adds IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, Stream stream, ExcelImageFormat imageFormat)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
System.IO.Stream | stream | Stream with the picture. |
ExcelImageFormat | imageFormat | Image format to use for picture storing. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Examples
The following code illustrates how to add a IPictureShape to the 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];
//Create image stream
Stream stream = new FileStream("image.png", FileMode.Open);
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, stream, ExcelImageFormat.Jpeg);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Stream, Int32, Int32)
Adds IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, Stream stream, int scaleWidth, int scaleHeight)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
System.IO.Stream | stream | Stream with the picture. |
System.Int32 | scaleWidth | Width scale in percents. |
System.Int32 | scaleHeight | Height scale in percents. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Examples
The following code illustrates how to add a IPictureShape to the 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];
//Create image stream
Stream stream = new FileStream("image.png", FileMode.Open);
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, stream, 50, 50);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Stream, Int32, Int32, ExcelImageFormat)
Adds IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, Stream stream, int scaleWidth, int scaleHeight, ExcelImageFormat imageFormat)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
System.IO.Stream | stream | Stream with the picture. |
System.Int32 | scaleWidth | Width scale in percents. |
System.Int32 | scaleHeight | Height scale in percents. |
ExcelImageFormat | imageFormat | Image format to use for picture storing. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Examples
The following code illustrates how to add a IPictureShape to the 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];
//Create image stream
Stream stream = new FileStream("image.png", FileMode.Open);
//Add image
IPictureShape picture = worksheet.Pictures.AddPicture(1, 1, stream, 50, 50, ExcelImageFormat.Jpeg);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Stream, Stream)
Creates a IPictureShape from the specified svg, its fallback image stream and adds the IPictureShape to the IPictures collection.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, Stream svgStream, Stream imageStream)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
System.IO.Stream | svgStream | Svg System.IO.Stream with the picture. |
System.IO.Stream | imageStream | The System.IO.Stream of fallback image. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Remarks
To know more about adding images of type SVG to worksheet refer Adding SVG Images.
Examples
The following code illustrates how to add a IPictureShape created with SvgData to the 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];
//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);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPicture(Int32, Int32, Stream, Stream, Int32, Int32)
Creates a IPictureShape from the specified svg, its fallback image stream and adds the IPictureShape to the IPictures collection with the provided scaling.
Declaration
IPictureShape AddPicture(int topRow, int leftColumn, Stream svgStream, Stream imageStream, int scaleWidth, int scaleHeight)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of a new picture. |
System.Int32 | leftColumn | Left column. |
System.IO.Stream | svgStream | Svg stream with the picture. |
System.IO.Stream | imageStream | The System.IO.Stream instance of fallback image. |
System.Int32 | scaleWidth | Width scale in percents. |
System.Int32 | scaleHeight | Height scale in percents. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Remarks
To know more about adding images of type SVG to worksheet refer Adding SVG Images.
Examples
The following code illustrates how to add a IPictureShape created with SvgData to the 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];
//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);
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}
AddPictureAsLink(Int32, Int32, Int32, Int32, String)
Adds a IPictureShape from the Url specified to the IPictures collection.
Declaration
IPictureShape AddPictureAsLink(int topRow, int leftColumn, int bottomRow, int rightColumn, string url)
Parameters
Type | Name | Description |
---|---|---|
System.Int32 | topRow | Top row of the picture to start with. |
System.Int32 | leftColumn | Left column of the picture to start with. |
System.Int32 | bottomRow | Bottom row of the picture to end with. |
System.Int32 | rightColumn | Right column of the picture to end with. |
System.String | url | Url of the picture. |
Returns
Type | Description |
---|---|
IPictureShape | Added picture. |
Remarks
To know more about adding images from web refer Adding Images from External Link.
Examples
The following code illustrates how to add a IPictureShape from an url specified to the 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 image
IPictureShape picture = worksheet.Pictures.AddPictureAsLink(1, 1, 5, 7, "https://cdn.syncfusion.com/content/images/company-logos/Syncfusion_Logo_Image.png");
//Save and dispose
workbook.SaveAs("Shapes.xlsx");
workbook.Close();
}