Document Solutions for Excel, .NET Edition | Document Solutions
File Operations / Export to PDF / Export Shapes
In This Topic
    Export Shapes
    In This Topic

    DsExcel .NET provides extensive support for loading, saving, printing and exporting Excel files comprising shapes and other drawing objects embedded in the worksheets.

    The IsPrintable property of the IShape interface can be used to get or set whether the object will be printed in the PDF document. By default, this value is TRUE and hence the shapes embedded in the Excel files are printed. In case you do not want to export shapes to the PDF files, this value must be set to FALSE.

    The Export Shapes to PDF feature allows users to print and export different types of shapes such as callouts, lines, rectangles, basic shapes, block arrows, flowcharts, equation shapes, stars and banners etc. This feature is useful especially when the following scenarios are encountered while working with spreadsheets:

    Using Code

    Refer to the following example code in order to export shapes to PDF.

    C#
    Copy Code
    // Initialize workbook
    Workbook workbook = new Workbook();
            
    // Fetch default worksheet 
    IWorksheet worksheet = workbook.Worksheets[0];
    
    // Adding Shapes
    IShape ShapeBegin = worksheet.Shapes.AddShape(AutoShapeType.CloudCallout, 1, 1, 100, 100);
    IShape EndBegin = worksheet.Shapes.AddShape(AutoShapeType.Wave, 200, 200, 100, 100);
            
    // Adding Connector Shape
    IShape ConnectorShape = worksheet.Shapes.AddConnector(ConnectorType.Straight, 1, 1, 101, 101);
    
    // Connect shapes by connector shape
    ConnectorShape.ConnectorFormat.BeginConnect(ShapeBegin, 3);
    ConnectorShape.ConnectorFormat.EndConnect(EndBegin, 0);
    
    // Get second shape in current worksheet(here it's a connector shape) and do not print it(default value is true)
    worksheet.Shapes[2].IsPrintable = false;
    
    // Saving workbook to PDF
    workbook.Save(@"ExportingShapesToPDF.pdf", SaveFileFormat.Pdf);

    Note: While exporting Excel files containing shapes into the PDF format, some of the exported shapes including the shapes with rectangular gradient fill and path gradient fill; shapes with multiple lines and gradient lines; shape effects like text distribution etc. may not look exactly the same as in Excel.