Back to Devexpress

ChartSheetExtensions.CreateThumbnail(ChartSheet, Int32, Int32) Method

officefileapi-devexpress-dot-spreadsheet-dot-chartsheetextensions-dot-createthumbnail-x28-devexpress-dot-spreadsheet-dot-chartsheet-system-dot-int32-system-dot-int32-x29.md

latest3.6 KB
Original Source

ChartSheetExtensions.CreateThumbnail(ChartSheet, Int32, Int32) Method

Saves the chart sheet as an image with the specified size.

You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use this method in production code.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Docs.v25.2.dll

NuGet Package : DevExpress.Document.Processor

Declaration

csharp
public static OfficeImage CreateThumbnail(
    this ChartSheet chartSheet,
    int width,
    int height
)
vb
<ExtensionAttribute>
Public Shared Function CreateThumbnail(
    chartSheet As ChartSheet,
    width As Integer,
    height As Integer
) As OfficeImage

Parameters

NameTypeDescription
chartSheetChartSheet

The chart sheet to be saved as an image.

| | width | Int32 |

The output image width in pixels.

| | height | Int32 |

The output image height in pixels.

|

Returns

TypeDescription
OfficeImage

The output image.

|

Remarks

If the chart sheet is bigger than the thumbnail, the chart sheet is cropped to fit the thumbnail. If the chart sheet is smaller, the remaining space is filled with the default background color.

The code sample below saves a chart sheet as an image:

csharp
using DevExpress.Spreadsheet;
// ...

// Create a new Workbook object.
using (Workbook workbook = new Workbook())
{
    // Load a workbook from a file.
    workbook.LoadDocument("VariableCosts.xlsx", DocumentFormat.Xlsx);

    // Access an active chart sheet.
    ChartSheet chartSheet = workbook.ChartSheets.ActiveChartSheet;

    // Save the chart sheet as an image.
    if (chartSheet != null)
        chartSheet.CreateThumbnail(920, 670).NativeImage.Save("Chart_sheet_Thumbnail.png");
}
vb
Imports DevExpress.Spreadsheet
' ...

' Create a new Workbook object.
Using workbook As New Workbook()
    ' Load a workbook from a file.
    workbook.LoadDocument("VariableCosts.xlsx", DocumentFormat.Xlsx)

    ' Access an active chart sheet.
    Dim chartSheet As ChartSheet = workbook.ChartSheets.ActiveChartSheet

    ' Save the chart sheet as an image.
    If chartSheet IsNot Nothing Then
        chartSheet.CreateThumbnail(920, 670).NativeImage.Save("Chart_sheet_Thumbnail.png")
    End If
End Using

See Also

ChartSheetExtensions Class

ChartSheetExtensions Members

DevExpress.Spreadsheet Namespace