Page tree

Versions Compared

Key

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

...

Code Block
pptt.Process();

5. Pass the Template object to PowerPointApplication so that Application methods can be used.

Code Block

PowerPointApplication ppta = new PowerPointApplication();
Presentation pres = ppta.Open(pptt);

7. We want to delete the last slide in our presentation, so we need to know how many slides there are. We can use Slides.Count to get this information.

Code Block

int numSlides = pres.Slides.Count;

6. Use the Slides.Delete method to delete the last slide. It takes an integer representing the index of the slide to delete as a parameter.

...

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);

...