How to save Chart and table on Presentation Slide as image in C#

Spire.Presentation enables developers to export the whole presentation slides with table, chart and shape to image. And it also supports to export the single element in the presentation slides, such as chart, table and shape into image. This article will show you how to save chart and table on Presentation Slide as image in C# and please check the steps as below:

Step 1: Create a presentation document and load from file.

Presentation ppt = new Presentation();
ppt.LoadFromFile("sample.pptx");

Step 2: Traverse every shape in the slide. Call ShapeList.SaveAsImage(int shapeIndex) to save table and chart as image.

//Save table as image in .Png format
Image image = ppt.Slides[0].Shapes.SaveAsImage(4);
image.Save("table.png", System.Drawing.Imaging.ImageFormat.Png);

//Save chart as image in .Jpeg format
image = ppt.Slides[1].Shapes.SaveAsImage(3);
image.Save("chart.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

You can use Shapes.SaveAsEMF method to save the chart and table to image in EMF format.

Effective screenshot:

Save Presentation table as image:

How to save Chart and table on Presentation Slide as image in C#

Save Presentation chart as image:

How to save Chart and table on Presentation Slide as image in C#

Full codes:

using Spire.Presentation;
using System.Drawing;

     namespace SaveTableChartasImage
{
    class Program
    {
        static void Main(string[] args)
        {
            Presentation ppt = new Presentation();
            ppt.LoadFromFile("sample.pptx");

            Image image = ppt.Slides[0].Shapes.SaveAsImage(4);
            image.Save("table.png", System.Drawing.Imaging.ImageFormat.Png);
            image = ppt.Slides[1].Shapes.SaveAsImage(3);
            image.Save("chart.jpg", System.Drawing.Imaging.ImageFormat.Jpeg);

            //ppt.Slides[1].Shapes.SaveAsEMF(3, "chart.emf");  
        }
    }
}