Page tree

Versions Compared

Key

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

...

  1. Open Microsoft PowerPoint and start with a blank .pptx file. Save the file as part1_template.pptx.
    # (optional) Set the presentation theme by going to the Design tab and selecting one of the built-in themes.
    # A title slide should have been added to the presentation by default. If not, then insert a title slide now.
    These will hold our data markers for the title, date and review status of the proposed product.

  2. Populate the title textbox with the data marker %%=Proposal.Name. When the template is processed, this data marker will get the value from the 'Name' column in the 'Proposal' data source.


    # In the subtitle box, add %%=Proposal.Date.
    # Insert a new textbox and place in near the bottom of the slide. This will hold the review status of the project. Type %%=Proposal.ReviewStatus into the box. Format with desired font size and formatting.
    The final slide should look something like the one below.
    !SlideOneFinal.png|border=1!
    # Insert a new content slide. This slide should consist of two text boxes: one for the title and a large one for the body of text.

  3. In the title text box, place the data marker %%=Proposal.Name. Note that this is the same as the data marker used on our first slide, and will be populated with the same data.
    # Add
    The rest of the slide will contain additional data about the proposal from the 'Proposal' data source. The data markers we are adding are: In the large text box add the following data markers:
  • %%=Proposal.

...

  • Start
  • %%=Proposal.Estimate

...

  • %%= Proposal.Summary

...

  • %%=Proposal.ReviewStatus.
    These will contain additional data about our project. PowerPointWriter supports data markers embedded in text, so only one text box is needed for all of our data markers.

The finished slide should look like the one below.

...

Info
titleFollowing the Sample Code

There is a sample web application page Part1.aspx and code behind Part1.aspx.cs available in the ProjectProposal/templates/part1_template.pptx directory that shows the completed code.

1#. Include the SoftArtisans.OfficeWriter.PowerPointWriter namespace in the code behind

Code Block
using SoftArtisans.OfficeWriter.PowerPointWriter;

2#. In the method that will actually create the presentation, instantiate the PowerPointTemplate object.

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 object for binding data to the template.

Code Block
DataBindingProperties dataProps = pptt.CreateDataBindingProperties();

5#. Create two arrays an array to hold the values for that will appear in 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" };

#. Create a second array that contains the column names. The column names values must match the data markers in the template.

Code Block
//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.

...