Table of Contents |
---|
This is Part 2 of a 3-part tutorial series for the Project Proposal scenario. It is recommended that you complete Part 1 - Getting Started before starting this section. |
There is a downloadable PowerPointWriter_BasicTutorials.zip with completed templates and code. The completed example of the template is available under ProjectProposal/templates/part2_template.pptx. The code for this part of the tutorial can be found in Part2.aspx.cs. |
This part focuses on taking advantage of PowerPointWriter's repeat slide behavior.
We are going to start with the template file as it was at the end of Part 1.
Our next slide will contain a list of estimated costs for the project.
6. 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.
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 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); |
1. Get the data for the Team and Cost data sets.
In the sample project, we are parsing CSV files with query results, rather than querying a live database. The CSV files are available under the data directory. There is a copy of the CSV parser, |
These calls are to a helper method GetCSVData
that parses the CSV files and returns a DataTable
with the values.
DataTable dtTeam = GetCSVData(Page.MapPath("//data//Part1_Team.csv")); DataTable dtCost = GetCSVData(Page.MapPath("//data//Part1_Cost.csv")); |
If you are following in your own project and would like to parse the CSV files as well, you will need to:
GenericParsing.dll
GeneringParsing
at the top of your code.GetCSVData
method that can be found in the sample code.2. Set the MaxRowsPerSlide property to be 10.
dataProps.MaxRowsPerSlide = 10; |
3. Bind the Team and Cost data sets to the template
pptt.BindData(dtTeam, "Team", dataProps); pptt.BindData(dtCost, "Cost", dataProps); |
4. Process the data
pptt.Process(); |
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.
pres.Slides.Delete(numSlides - 1); |
7.Save the final presentation and stream it in the response.
ppta.Save(pres, Page.Response, "Part2_Output.pptx", false); |
For information on writing this code, see Part 1 - Getting Started. |
//Code from Part 1 PowerPointTemplate pptt = new PowerPointTemplate(); pptt.Open(Page.MapPath("//templates//part1_template.pptx")); DataBindingProperties dataProps = pptt.CreateDataBindingProperties(); object[] valuesArray = { "Surgery Schedule", "January 1, 2014", "Under Review", "Pamela Blythe", "January 1, 2015", "6 months", "Software to schedule surgeries that require multiple resources such as surgeons, assistants, nurses, pre-op and post-op space, surgery theater, long-term recovery rooms." }; string[] columnNamesArray = { "Name", "Date", "ReviewStatus", "Leader", "Start", "Estimate", "Summary" }; //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(); ppta.Save(Page.Response, "Part2_Output.pptx", false); |
You can download the code for the Basic PowerPointWriter Tutorials as a Visual Studio solution, which includes the Project Proposal.
Continue on to Part 3 - Passing to PowerPointApplication