Skip to main content
A newer version of this page is available. .
All docs
V21.2
.NET Framework 4.5.2+
Row

ChartSheetExtensions.CreateThumbnail(ChartSheet, Int32, Int32, SheetThumbnailOptions) Method

Saves the chart sheet as an image. Allows you to specify the image size and thumbnail options.

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.v21.2.dll

Declaration

public static OfficeImage CreateThumbnail(
    this ChartSheet chartSheet,
    int width,
    int height,
    SheetThumbnailOptions options
)

Parameters

Name Type Description
chartSheet ChartSheet

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.

options SheetThumbnailOptions

An object that defines thumbnail options.

Returns

Type Description
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 background color.

The code sample below specifies thumbnail options and saves a chart sheet as an image:

Generate a Thumbnail from the Chart Sheet

using DevExpress.Spreadsheet;
using System.Drawing;
// ...

// 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;

    // Specify thumbnail options.
    var thumbnailOptions = new SheetThumbnailOptions
    {
        Resolution = 192,
        Scale = 40,
        BackgroundColor = Color.FromArgb(0xF2, 0xF2, 0xF2)
    };

    // Save the chart sheet as an image.
    if (chartSheet != null)
        chartSheet.CreateThumbnail(800, 600, thumbnailOptions).NativeImage.Save("Chart_sheet_Thumbnail.png");
}
See Also