Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Description

This sample demonstrates how to use PowerPointWriter to programatically create Certificates of Completion for a group of students.

The Data

Our Excel file contains the names of the students who are receiving a certificate.

!data.png!

The Template

Our template presentation has a single slide that will be repeated for each student. 

!template.png!


h3. The Code

The code below creates a data table containing some of the names of the students. It then binds the names and information about the course to the presentation. See Extracting Data from Excel to learn how to extract data directly from the Excel spreadsheet.

Code Block
public void CreateCertificates()
{
using (PowerPointTemplate ppt = new PowerPointTemplate())
{
ppt.RemoveExtraDataMarkers = true;
ppt.Open(@"C:..\..\inputs\CertificateTemplate.pptx");
//Certificate data
string[] colNames = {"Course", "Date", "InstructorSignature", "InstructorName"};
object[] values = {"PowerPointWriter Training Program", "March 1, 2015",
System.IO.File.ReadAllBytes(@"C:..\..\inputs\InstructorSignature.png"), "Aileen J. Grossman"
};
ppt.BindData(values, colNames, "Certificate", ppt.CreateDataBindingProperties());
//Student names (to repeat)
DataTable studentdt = new DataTable();
studentdt.Columns.Add("Name");
studentdt.Rows.Add(new object[] {"Noemi H. Paulson"});
studentdt.Rows.Add(new object[] {"Laura R. Pyles"});
studentdt.Rows.Add(new object[] {"Mildred C. Cassette"});
studentdt.Rows.Add(new object[] {"Dominic C. Perkins"});
studentdt.Rows.Add(new object[] {"Marcie C. Fenske"});
studentdt.Rows.Add(new object[] {"Ernest L. Hanlon"});
studentdt.Rows.Add(new object[] {"Betty R. Gibson"});
studentdt.Rows.Add(new object[] {"Derick E. Hayden"});
studentdt.Rows.Add(new object[] {"Ron M. McCowan"});
studentdt.Rows.Add(new object[] {"Lawrence P. Nichols"});
DataBindingProperties dataProps = ppt.CreateDataBindingProperties();
dataProps.MaxRowsPerSlide = 1;
ppt.BindData(studentdt, "Students", dataProps);
ppt.Process();
ppt.Save(@"C:..\..\outputs\CertificatesOut.pptx");
}
}

Result

The resulting output shows all the data from the Excel spreadsheet in a PowerPoint presentation table.

!output.png!

 

Downloads

* Image: [Certificate Slide Deck^InstructorSignature.png]
* Template: [Certificate Slide Deck^CertificateTemplate.pptx]
* Sample output: [Certificate Slide Deck^CertificatesOut.pptx]