Page tree

Versions Compared

Key

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

Table of Contents

Table of Contents
maxLevel2

Intro

Note

This is Part 2 of a 2-part tutorial series for the Project Proposal scenario. It is recommended that you complete Part 1 - Getting Started before starting this section.

...

This part focuses on taking advantage of PowerPointWriter's repeat slide behavior. It also covers passing between the Template and Application objects and deleting slides.

Adding to the Template

Importing Multiple Rows

We are going to start with the template file as it was at the end of Part 1. Add a new slide with the title 'Team Members'. This slide will contain data from the 'Team' data source about the proposed team members for the new project.

...

In the first row of the table, add the headers 'Name', 'Role', 'Joined', and 'Previous Experience'. In the second row, add the corresponding data markers: %%=Team.Name, %%=Team.Role, %%=Team.YearJoined, and %%=Team.Experience. Finally, add the data marker %%=Proposal.ReviewStatus somewhere at the bottom of the slide. Your completed slide should look like the following:

Fitting Data on to Multiple Slides

Our next slide will contain a list of estimated costs for the project. Create a new slide and give it the title 'Expected Costs' and add %%=Proposal.ReviewStatus to the bottom of the slide. Then, add a table with 2 rows and 3 columns.

...

To use the RepeatSlide marker, add the text '%%RepeatSlide' as the first string of text in the notes section of the 'Expected Costs' slide. Make sure there is a space between %%RepeatSlide and the next item of text. The completed slide should look like the one below. Note the RepeatSlide marker in the notes section of the slide.

Writing the Code

We will reuse the code from Part 1 of this tutorial. We will take out the Process and Save calls and add our new code for Part 2.

...

Code Block
ppta.Save(pres, Page.Response, "Part2_Output.pptx", false);

Final Code

Note

For information on writing this code, see Part 1 - Getting Started.

Code Block
//Code from Part 1
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);
//Code from Part 2
DataTable dtTeam = GetCSVData(Page.MapPath("//data//Team.csv"));
DataTable dtCost = GetCSVData(Page.MapPath("//data//Cost.csv"));
dataProps.MaxRowsPerSlide = 10;
pptt.BindData(dtTeam, "Team", dataProps);
pptt.BindData(dtCost, "Cost", dataProps);
pptt.Process();
PowerPointApplication ppta = new PowerPointApplication();
Presentation pres = ppta.Open(pptt);
int numSlides = pres.Slides.Count;
pres.Slides.Delete(numSlides - 1);
ppta.Save(pres, Page.Response, "Part2_Output.pptx", false);

Downloads

You can download the code for the Basic PowerPointWriter Tutorials as a Visual Studio solution, which includes the Project Proposal.

...