PNG JPG BMP TIFF XLSX
Aspose.Cells  for .NET

Get Images/Pictures Size In Excel via .NET

Using Aspose.Cells’ API to work with various objects without any software like Microsoft or Open Office, Adobe PDF, etc.

How to get images/pictures size in Excel File Using C#

In order to get images/pictures size in Excel File, we’ll use

Aspose.Cells for .NET

API which is a feature-rich, powerful and easy to use document manipulation and splitter API for C# platform. Open

NuGet

package manager, search for Aspose.Cells and install. You may also use the following command from the Package Manager Console.

Command


PM> Install-Package Aspose.Cells

Steps to get images/pictures size in Excel file via C#

You need the aspose.cells.dll to try the following workflow in your own environment.

  • Loading the XLSX file with full path.
  • Select Worksheet via its index.
  • Select picture object via its index from ‘Pictures’ attribute of Worksheet.
  • There are various ways to get the size from a selected picture object.The parts are listed below, for more information, please refer to MORE .Notice:‘Width’ and ‘Height’ are the dimensions shown in the excel may be larger or smaller than the original picture.
    • Width Represents the width of shape, in unit of pixels.
    • Height Represents the height of shape, in unit of pixel.
    • OriginalWidth Gets the original width of the picture, in unit of pixels.
    • OriginalHeight Gets the original height of the picture, in unit of pixels.

System Requirements

Aspose.Cells for .NET is supported on all major operating systems. Just make sure that you have the following prerequisites.

  • Microsoft Windows or a compatible OS with .NET Framework, .NET Core, Mono or Xamarin Platforms
  • Development environment like Microsoft Visual Studio
  • Add reference to the Aspose.Cells for .NET DLL in your project - Install from NuGet using the Download button above

There are also two size-related attributes ‘WidthScale’ and ‘HeightScale’, which respectively represent the percentages of the current display width and height to the actual width and height. It should be noted that there is a certain error in these two attribute values, please do not use them in the case of high precision requirements.

The following code sample demonstrates how to get the size and display zoom ratio of an image/picture.

 

Get size of images/pictures - C#

 
  • About Aspose.Cells for .NET API

    Aspose.Cells API can be used to create, edit, convert and render Microsoft Excel formats to different formats. Moreover, it can be used for comprehensive charting, scalable reporting and reliable calculations within software applications. Aspose.Cells is a standalone API and it does not require any software like Microsoft or OpenOffice.