Page tree

Versions Compared

Key

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

...

Code Block
PowerPointTemplate PPTT = new PowerPointTemplate();

3. Open the template file for the presentation.

Code Block

pptt.Open(Page.MapPath("//templates//part1_template.pptx"));

4. Create a DatabindingProperties ibject for binding data to the template.

Code Block

DataBindingProperties dataProps = pptt.CreateDataBindingProperties();

5. Create two arrays to hold the values for the presentation. The first is the array of values to add to the presentation. The second contains the column names. The column names values must match the data markers in the template.

Code Block

//The values to display
 object[] valuesArray = { "Project Name", "Project Date", "Review", "Leader Name", "Start Date", "Cost Estimate", "Project Summary" };

//The column names are the same as the data markers
string[] columnNamesArray = {"Name", "Date", "ReviewStatus", "Leader", "Start", "Estimate", "Summary"};

6. Bind the data to the template. Make sure the data source name is the same as the name used in the template.

Code Block

pptt.BindData(valuesArray, columnNamesArray, "Proposal", dataProps);

7. Call process to import the data into the template and save the file.
pptt.Process();

//Stream the output in the response as an attachment
pptt.Save(Page.Response, "Part1_Output.xlsx", false);

Final Code

Code Block

PowerPointTemplate pptt = new PowerPointTemplate();
pptt.Open(Page.MapPath("//templates//part1_template.pptx"));
DataBindingProperties dataProps = pptt.CreateDataBindingProperties();
object[] valuesArray = { "Project Name", "Project Date", "Review", "Leader Name", "Start Date", "Cost Estimate", "Project Summary" };
string[] columnNamesArray = {"Name", "Date", "ReviewStatus", "Leader", "Start", "Estimate", "Summary"};
pptt.BindData(valuesArray, columnNamesArray, "Proposal", dataProps);
pptt.Process();
pptt.Save(Page.Response, "Part1_Output.xlsx", false)

Downloads

Next Steps

You have now completed part 1 of the PowerPointWriter Project Proposal tutorial.