Skip to main content
All docs
V26.1
  • Row

    Shape.ExportToImage(String, ImageFileFormat) Method

    SECURITY-RELATED CONSIDERATIONS

    Using file paths sourced from untrusted input may expose unauthorized files or allow unintended file access. Always validate and normalize all external paths to prevent path manipulation.

    Saves the drawing object as an image in the specified format.

    Namespace: DevExpress.Spreadsheet

    Assembly: DevExpress.Spreadsheet.v26.1.Core.dll

    NuGet Package: DevExpress.Spreadsheet.Core

    Declaration

    void ExportToImage(
        string fileName,
        ImageFileFormat format
    )

    Parameters

    Name Type Description
    fileName String

    The file name (including the full path) for the output image.

    format ImageFileFormat

    The output image format.

    Remarks

    Call the ExportToImage method to save a drawing object (chart, picture, or shape) as an image. The image includes all display settings of the drawing object (for example, crop, outline, and effects).

    Example: Save a Text Box as an Image

    The following code snippet creates a text box and saves the text box as a PNG image:

    using System.Drawing;
    using System.IO;
    using DevExpress.Spreadsheet;
    
    using var workbook = new Workbook();
    var worksheet = workbook.Worksheets[0];
    
    var textBox = worksheet.Shapes.AddTextBox(50, 120, 500, 250, "Spreadsheet");
    textBox.Fill.SetSolidFill(Color.PowderBlue);
    
    Directory.CreateDirectory("output");
    textBox.ExportToImage(Path.Combine("output", "TextBox.png"), ImageFileFormat.Png);
    
    See Also