Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

 

Introducedin
09.1

Description

Excerpt

Saves a Chart an Area as a specified image format at with specific dimensions in pixels at a specified file path with the specified dimensions in pixels.

Signature
C#
C#
 public static void SaveImage(String filePath, ImageFormat imageFormat, int? width, int? height)
Signature
vb.net
vb.net
Public Static Sub SaveImage(ByVal filePath As String, ByVal imageFormat As ImageFormat, ByVal width As int?, ByVal height As int?)

Parameters

Param
0filePath

A string representing the filepath you would like to save the image to.

Param
0ImageFormat

The file format ExcelWriter will save the chart area as. Supported file types include GIF, JPEG, BMP, PNG, EMF, TIFF, and WMF

Param
0width

The desired width of the image in pixels

Param
0height

The desired height of the image in pixels.

 

Exceptions

Exception
System.Exception
System.Exception

If there is a problem creating, opening, or writing to the file specified, or reading from the Chart Area object.

Example
Code Block
csharp
csharp
titleC#
           ExcelApplication xla = new ExcelApplication();
           Workbook WB= xla.Create(FileFormat.Xlsx);
           ChartArea chartOneareaOne= WB[0].Charts[0CreateArea["A1:C5"];          
           chartOneareaOne.SaveImage("Path/filename.png", System.Drawing.Imaging.ImageFormat.Png, 240300, 180400);            
Code Block
vb.net
vb.net
titlevb.net
	   Dim oExcelApp As New ExcelApplication()           
           Dim wb As Workbook = oExcelApp.Create(FileFormat.Xlsx) 
           Dim chartOneareaOne As ChartArea = WB[0].Charts[0CreateArea["A1:C5"]       
              chartOneareaOne.SaveImage("Path/filename.png"), System.Drawing.Imaging.ImageFormat.Png, 240300, 180400)