officefileapi-devexpress-dot-spreadsheet-dot-chartsheetextensions-dot-createthumbnail-x28-chartsheet-stream-imagefileformat-int32-int32-sheetthumbnailoptions-x29.md
Saves the chart sheet as an image in the specified format. 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.v25.2.dll
NuGet Package : DevExpress.Document.Processor
public static void CreateThumbnail(
this ChartSheet chartSheet,
Stream stream,
ImageFileFormat format,
int width,
int height,
SheetThumbnailOptions options
)
<ExtensionAttribute>
Public Shared Sub CreateThumbnail(
chartSheet As ChartSheet,
stream As Stream,
format As ImageFileFormat,
width As Integer,
height As Integer,
options As SheetThumbnailOptions
)
| Name | Type | Description |
|---|---|---|
| chartSheet | ChartSheet |
The chart sheet to be saved as an image.
| | stream | Stream |
A stream used to save the output image.
| | format | ImageFileFormat |
The output image format.
| | width | Int32 |
The output image width in pixels.
| | height | Int32 |
The output image height in pixels.
| | options | SheetThumbnailOptions |
An object that defines thumbnail options.
|
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:
using DevExpress.Spreadsheet;
using System.Drawing;
using System.IO;
// ...
// 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)
{
using (FileStream stream = new FileStream("Chart_ sheet_Thumbnail.png", FileMode.Create))
{
chartSheet.CreateThumbnail(stream, ImageFileFormat.Png, 800, 600, thumbnailOptions);
}
}
}
Imports DevExpress.Spreadsheet
Imports System.Drawing
Imports System.IO
' ...
' 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
' Specify thumbnail options.
Dim thumbnailOptions = New SheetThumbnailOptions With {
.Resolution = 192,
.Scale = 40,
.BackgroundColor = Color.FromArgb(&HF2, &HF2, &HF2)
}
' Save the chart sheet as an image.
If chartSheet IsNot Nothing Then
Using stream As New FileStream("Chart_sheet_Thumbnail.png", FileMode.Create)
chartSheet.CreateThumbnail(stream, ImageFileFormat.Png, 800, 600, thumbnailOptions)
End Using
End If
End Using
See Also