Articles in this section
Category / Section

How to generate reports in PowerPoint presentations for data from database?

3 mins read

You can generate reports in PowerPoint presentations for the data from database, using Presentation and XlsIO libraries. This can be done in Windows Forms, WPF, ASP.NET, ASP.NET MVC, UWP and Xamarin platforms. For more information about the platform-wise required assemblies, please refer the UG documentation here.

Step 1: Import data from database to an excel file using XlsIO library


The below links demonstrates importing data from a database to an excel file.


KB link:



Excel file using XlsIO library


Step 2: Create charts and tables in a PowerPoint presentation for the data in excel sheet

The following screenshot and code example demonstrates importing data from an excel work sheet as charts and tables in a PowerPoint slide.


Data Excel sheet



The below code example demonstrates creating tables and charts in a PowerPoint slide, for the data from different data-ranges of an excel sheet.


// Open presentation by using Essential Presentation.
IPresentation presentation = Presentation.Open("Sample.pptx");
int count = 0;
//Export the date from excel to Presentation
foreach (DataTable splittedDataTable in dataTables)
if (count == 1)
ExportToPresentation(presentation, splittedDataTable);
//Add slide to the PowerPoint presentation
ISlide slide = presentation.Slides[0];
//Get the excel file as stream
Stream stream = new FileStream("Microsoft_Excel_Worksheet.xlsx", FileMode.Open);
stream.Position = 0;
//Create a chart for the date in excel file within A1:F6 data range
IPresentationChart columnChart = slide.Charts.AddChart(stream, 1, "A1:F6", new RectangleF(30.96F, 15.12F, 350.64F, 227.52F));
stream.Position = 0;
//Create a chart for the date in excel file within A7:D12 data range
IPresentationChart pieChart = slide.Charts.AddChart(stream, 1, "A7:D12", new RectangleF(30.96F, 289.44F, 350.64F, 227.52F));
//Set the chart type as Pie.
pieChart.ChartType = Syncfusion.OfficeChart.OfficeChartType.Pie;
//Dispose the stream
//Save the presentation
///Exports the values in data table to PowerPoint tables.
private static void ExportToPresentation(IPresentation presentation, DataTable dataTable)
//Add slide to the presentation document.
ISlide slide = presentation.Slides[0];
//Add table to the slide. The height of the table will grow per the content height by default
ITable table = slide.Tables.AddTable(dataTable.Rows.Count, dataTable.Columns.Count 1, 416.16, 101.28, 500.2, 165.36);
//Disable the header row property
table.HasHeaderRow = true;
int rowIndex = 0;
int colIndex = 0;
//Add data to the table in presentation from the DataTable instance
foreach (DataRow row in dataTable.Rows)
foreach (object val in row.ItemArray)
ICell cell = table[rowIndex, colIndex];
if (colIndex == 5)
colIndex = 0;


Sample Link:



Did you find this information helpful?
Help us improve this page
Please provide feedback or comments
Comments (0)
Please sign in to leave a comment