Back to Devexpress

WorksheetThumbnailOptions Class

officefileapi-devexpress-dot-spreadsheet-c731f394.md

latest3.8 KB
Original Source

WorksheetThumbnailOptions Class

Contains options used to generate a thumbnail from a worksheet.

Namespace : DevExpress.Spreadsheet

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
public class WorksheetThumbnailOptions :
    SheetThumbnailOptions
vb
Public Class WorksheetThumbnailOptions
    Inherits SheetThumbnailOptions

Remarks

Use the WorksheetExtensions.CreateThumbnail extension method of a Worksheet object to save a worksheet as an image. Create a WorksheetThumbnailOptions instance and pass it to this method to specify thumbnail options.

Important

The WorksheetExtensions class is defined in the DevExpress.Docs.v25.2.dll assembly. You need a license for the DevExpress Office File API Subscription or DevExpress Universal Subscription to use this assembly in production code.

The following example demonstrates how to save a worksheet as an image and set thumbnail options:

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

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

    // Access an active worksheet.
    Worksheet worksheet = workbook.Worksheets.ActiveWorksheet;

    // Specify thumbnail options.
    var thumbnailOptions = new WorksheetThumbnailOptions
    {
        Resolution = 192,
        Scale = 80,
        Stretch = true,
        ColumnOffset = 1,
        RowOffset = 1,
        BackgroundColor = Color.FromArgb(0xF2, 0xF2, 0xF2)
    };

    // Create the worksheet's thumbnail and save it to a file.
    worksheet.CreateThumbnail("Worksheet_Thumbnail.png", ImageFileFormat.Png, 1600, 900, thumbnailOptions);
}
vb
Imports DevExpress.Spreadsheet
Imports System.Drawing
' ...

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

    ' Access an active worksheet.
    Dim worksheet As Worksheet = workbook.Worksheets.ActiveWorksheet

    ' Specify thumbnail options.
    Dim thumbnailOptions = New WorksheetThumbnailOptions With {
      .Resolution = 192,
      .Scale = 80,
      .Stretch = True,
      .ColumnOffset = 1,
      .RowOffset = 1,
      .BackgroundColor = Color.FromArgb(&HF2, &HF2, &HF2)
    }

    ' Create the worksheet's thumbnail image and save it to a file.
    worksheet.CreateThumbnail("Worksheet_Thumbnail.png", ImageFileFormat.Png, 1600, 900, thumbnailOptions)
End Using

Inheritance

Object SheetThumbnailOptions WorksheetThumbnailOptions

See Also

WorksheetThumbnailOptions Members

DevExpress.Spreadsheet Namespace