VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
In This Topic
    XLSX: Work with drawing objects (pictures, charts, shapes) on XLSX page
    In This Topic
    SpreadsheetEditorControl and WpfSpreadsheetEditorControl controls allow to work (view, add, set, delete) with drawing objects of XLSX worksheet in desktop (WinForms, WPF) application.

    The drawing object is a picture, chart or shape. The drawing objects can be changed visually using mouse/keyboard or programmatically.


    Add new picture to the XLSX worksheet

    Here is C# and VB.NET code that demonstrates how to add a new picture to the focused XLSX worksheet:
    public void AddPictureToXlsxWorksheet(
        Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl,
        System.IO.Stream imageStream)
    {
        // get visual editor for spreadsheet document
        Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;
    
        // create image data
        Vintasoft.Imaging.ImageData imagedata = new Vintasoft.Imaging.ImageData(imageStream);
    
        // add image to the focused worksheet
        spreadsheetVisualEditor.AddPicture(imagedata);
    }
    
    Public Sub AddPictureToXlsxWorksheet(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl, imageStream As System.IO.Stream)
        ' get visual editor for spreadsheet document
        Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor
    
        ' create image data
        Dim imagedata As New Vintasoft.Imaging.ImageData(imageStream)
    
        ' add image to the focused worksheet
        spreadsheetVisualEditor.AddPicture(imagedata)
    End Sub
    


    Set a bitmap for existing picture on the XLSX worksheet

    Here is C# and VB.NET code that demonstrates how to set a bitmap for existing picture on the XLSX worksheet:
    public void SetPictureOnFocusedXlsxWorksheet(
        Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl,
        System.IO.Stream imageStream)
    {
        // get visual editor for spreadsheet document
        Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;
    
        // if focused worksheet does not have focused drawing
        if (spreadsheetVisualEditor.FocusedDrawing == null)
            throw new System.Exception("Worksheet does not have focused drawing.");
    
        // create image data
        Vintasoft.Imaging.ImageData imagedata = new Vintasoft.Imaging.ImageData(imageStream);
    
        // set image for focused drawing
        spreadsheetVisualEditor.SetDrawingPicture(imagedata);
    }
    
    Public Sub SetPictureOnFocusedXlsxWorksheet(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl, imageStream As System.IO.Stream)
        ' get visual editor for spreadsheet document
        Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor
    
        ' if focused worksheet does not have focused drawing
        If spreadsheetVisualEditor.FocusedDrawing Is Nothing Then
            Throw New System.Exception("Worksheet does not have focused drawing.")
        End If
    
        ' create image data
        Dim imagedata As New Vintasoft.Imaging.ImageData(imageStream)
    
        ' set image for focused drawing
        spreadsheetVisualEditor.SetDrawingPicture(imagedata)
    End Sub
    


    Resize a drawing object of XLSX worksheet

    If you want to resize the drawing object of XLSX worksheet using mouse, you should do the following steps:


    Move a drawing object of XLSX worksheet

    If you want to move (reposition) the drawing object of XLSX worksheet using mouse, you should do the following steps:


    Delete the picture from XLSX worksheet

    Here is C# and VB.NET code that demonstrates how to delete the picture from XLSX worksheet:
    public void DeletePictureFromXlsxWorksheet(Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl editorControl)
    {
        // get visual editor for spreadsheet document
        Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor spreadsheetVisualEditor = editorControl.VisualEditor;
    
        // if focused worksheet does not have focused drawing
        if (spreadsheetVisualEditor.FocusedDrawing == null)
            throw new System.Exception("Worksheet does not have focused drawing.");
    
        // delete the focused picture from the focused worksheet
        spreadsheetVisualEditor.RemoveFocusedDrawing();
    }
    
    Public Sub DeletePictureFromXlsxWorksheet(editorControl As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetEditorControl)
        ' get visual editor for spreadsheet document
        Dim spreadsheetVisualEditor As Vintasoft.Imaging.Office.Spreadsheet.UI.SpreadsheetVisualEditor = editorControl.VisualEditor
    
        ' if focused worksheet does not have focused drawing
        If spreadsheetVisualEditor.FocusedDrawing Is Nothing Then
            Throw New System.Exception("Worksheet does not have focused drawing.")
        End If
    
        ' delete the focused picture from the focused worksheet
        spreadsheetVisualEditor.RemoveFocusedDrawing()
    End Sub