Message-ID: <586407913.8705.1711656609017.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_8704_460657164.1711656609017" ------=_Part_8704_460657164.1711656609017 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
Table of Contents | =20
---|
=20
| =20
This part focuses on passing a presentation between PowerPointTemplate a= nd PowerPointApplication in order to take advantage of the full range of fe= atures available with PowerPointWriter.
=20We will continue adding to our template from Part 2. The next part of our presentatio= n will contain information about the Team the new employee will be working = on.
=20This is the 8th and final slide in our template. This slide will be used= as a template slide for 4 different data sets. To achieve this we will use= the Slides.Copy method and the Slide data binding p= roperty.
=20We will start with an unprocessed template file containing all of the sl= ides from the 3 parts of this tutorial.
=20PowerPointApplication ppta =3D new PowerPointApplication();=20
Presentation pres =3D ppta.Open(Page.MapPath("//templates//part3_templ= ate.pptx"));=20
Slide slideToCopy =3D pres.Slides[7];=20
pres.Slides.CopySlide(slideToCopy, (pres.Slides.Count)); pres.Slides.CopySlide(slideToCopy, (pres.Slides.Count)); pres.Slides.CopySlide(slideToCopy, (pres.Slides.Count));=20
PowerPointTemplate pptt =3D new PowerPointTemplate(); pptt.Open(ppta, pres);=20
//Code from Part 1 PowerPointTemplate pptt =3D new PowerPointTemplate(); pptt.Open(Page.MapPath("//templates//part1_template.pptx")); DataBindingProperties dataProps =3D pptt.CreateDataBindingProperties(); string[] columnNamesArray =3D {"Logo"}; Byte[] logoArray =3D System.IO.File.ReadAllBytes((Page.MapPath("//data= //logo.png"))); object[] valuesArray =3D {logoArray}; pptt.BindData(valuesArray, columnNamesArray, "Company", dataProps= ); string[] employeeColNames =3D {"Name", "Team"}; object[] employeeValues =3D {"Amy Alberts", "= ;Development"}; pptt.BindData(employeeValues, employeeColNames, "Employee", dataP= rops); DataTable teamData =3D GetCSVData((Page.MapPath("//data//Team.csv"= ;))); pptt.BindData(teamData, "Team", dataProps); //Code from Part 2 DataTable dtCompanyHistory =3D GetCSVData(Page.MapPath("//data//Compan= yHistory.csv")); dataProps.MaxRowsPerSlide =3D 5; pptt.BindData(dtCompanyHistory, "CompanyHistory", dataProps); DataTable dtProducts =3D GetCSVData(Page.MapPath("//data//Products.csv= ")); DataBindingProperties dataProps2 =3D pptt.CreateDataBindingProperties(); dataProps2.MaxRowsPerSlide =3D 2; pptt.BindData(dtProducts, "Products", dataProps2);=20
string[] titleCol =3D { "TrainingItem" };=20
//Data for the TrainingItem data source object[] titleArrayTeam =3D { "Team Members" }; //Get the Team members data DataTable dtTeamMembers =3D GetCSVData(Page.MapPath("//data//TeamMembe= rs.csv"));=20
dataProps.Slide =3D 7;=20
pptt.BindData(titleArrayTeam, titleCol, "Department", dataProps); pptt.BindData(dtTeamMembers, "TrainingItems", dataProps);=20
//The 9th slide will be 'Agile Development / Scrum' object[] titleArrayAgile =3D { "Agile Development / Scrum" }; DataTable dtAgile =3D GetCSVData(Page.MapPath("//data//Agile.csv"= )); dataProps.Slide =3D 8; pptt.BindData(titleArrayAgile, titleCol, "Department", dataProps)= ; pptt.BindData(dtAgile, "TrainingItems", dataProps); //The 10th slide will be 'Resources and Utilities' object[] titleArrayResources =3D { "Resources and Utilities" }; DataTable dtResources =3D GetCSVData(Page.MapPath("//data//Resources.c= sv")); dataProps.Slide =3D 9; pptt.BindData(titleArrayResources, titleCol, "Department", dataPr= ops); pptt.BindData(dtResources, "TrainingItems", dataProps); //The final slide will be 'Expectations' object[] titleArrayExpectations =3D { "Expectations" }; DataTable dtExpectations =3D GetCSVData(Page.MapPath("//data//Expectat= ions.csv")); dataProps.Slide =3D 10; pptt.BindData(titleArrayExpectations, titleCol, "Department", dat= aProps); pptt.BindData(dtExpectations, "TrainingItems", dataProps);=20
pptt.Process(); pptt.Save(Page.Response, "part3_OutPut.pptx", false);=20
PowerPointApplication ppta =3D new PowerPointApplication(); Presentation pres =3D ppta.Open(Page.MapPath("//templates//part3_templ= ate.pptx")); Slide slideToCopy =3D pres.Slides[7]; pres.Slides.CopySlide(slideToCopy, (pres.Slides.Count)); pres.Slides.CopySlide(slideToCopy, (pres.Slides.Count)); pres.Slides.CopySlide(slideToCopy, (pres.Slides.Count)); PowerPointTemplate pptt =3D new PowerPointTemplate(); pptt.Open(ppta, pres); //Code from Part 1 DataBindingProperties dataProps =3D pptt.CreateDataBindingProperties(); string[] columnNamesArray =3D { "Logo" }; Byte[] logoArray =3D System.IO.File.ReadAllBytes((Page.MapPath("//data= //logo.png"))); object[] valuesArray =3D { logoArray }; pptt.BindData(valuesArray, columnNamesArray, "Company", dataProps= ); string[] employeeColNames =3D { "Name", "Team" }; object[] employeeValues =3D { "Amy Alberts", "Development&qu= ot; }; pptt.BindData(employeeValues, employeeColNames, "Employee", dataP= rops); DataTable teamData =3D GetCSVData((Page.MapPath("//data//Team.csv"= ;))); pptt.BindData(teamData, "Team", dataProps); //Code from Part 2 DataTable dtCompanyHistory =3D GetCSVData(Page.MapPath("//data//Compan= yHistory.csv")); dataProps.MaxRowsPerSlide =3D 5; pptt.BindData(dtCompanyHistory, "CompanyHistory", dataProps); DataTable dtProducts =3D GetCSVData(Page.MapPath("//data//Products.csv= ")); DataBindingProperties dataProps2 =3D pptt.CreateDataBindingProperties(); dataProps2.MaxRowsPerSlide =3D 2; pptt.BindData(dtProducts, "Products", dataProps2); //add the data from part 3 string[] titleCol =3D { "TrainingItem" }; object[] titleArrayTeam =3D { "Team Members" }; DataTable dtTeamMembers =3D GetCSVData(Page.MapPath("//data//TeamMembe= rs.csv")); dataProps.Slide =3D 7; pptt.BindData(titleArrayTeam, titleCol, "Department", dataProps); pptt.BindData(dtTeamMembers, "TrainingItems", dataProps); object[] titleArrayAgile =3D { "Agile Development / Scrum" }; DataTable dtAgile =3D GetCSVData(Page.MapPath("//data//Agile.csv"= )); dataProps.Slide =3D 8; pptt.BindData(titleArrayAgile, titleCol, "Department", dataProps)= ; pptt.BindData(dtAgile, "TrainingItems", dataProps); object[] titleArrayResources =3D { "Resources and Utilities" }; DataTable dtResources =3D GetCSVData(Page.MapPath("//data//Resources.c= sv")); dataProps.Slide =3D 9; pptt.BindData(titleArrayResources, titleCol, "Department", dataPr= ops); pptt.BindData(dtResources, "TrainingItems", dataProps); object[] titleArrayExpectations =3D { "Expectations" }; DataTable dtExpectations =3D GetCSVData(Page.MapPath("//data//Expectat= ions.csv")); dataProps.Slide =3D 10; pptt.BindData(titleArrayExpectations, titleCol, "Department", dat= aProps); pptt.BindData(dtExpectations, "TrainingItems", dataProps); pptt.Process(); pptt.Save(Page.Response, "part3_OutPut.pptx", false);=20
You can download the code for the Basic PowerPointWriter Tutorials as a = Visual Studio solution, which includes the Project Proposal.
=20 =20See our Quick Guides and Samples for more advanced topics.