Message-ID: <1929612567.9513.1711692763238.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_9512_2113483021.1711692763238" ------=_Part_9512_2113483021.1711692763238 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
The data for this sample is a data table of randomly generated college a= dmission test scores. The following code is used to generate the data table= .
private DataTable GetScores() { DataTable dt =3D new DataTable(); dt.Columns.Add("StudentID", typeof(string)); dt.Columns.Add("Reading", typeof(int)); dt.Columns.Add("Writing", typeof(int)); dt.Columns.Add("Math", typeof(int)); dt.Columns.Add("Total", typeof(int)); Random rand =3D new Random(); int rScore, wScore, mScore; for (int i =3D 0; i < 30; ++i) { rScore =3D rand.Next(400, 800); wScore =3D rand.Next(400, 800); mScore =3D rand.Next(400, 800); dt.Rows.Add( string.Format("S{0:000000}", rand.NextDouble() * 1000000), rScore, wScore, mScore, rScore + wScore + mScore ); } DataTable dtSorted =3D dt.Clone(); foreach (DataRow row in dt.Select("", "StudentID asc")) dtSorted.ImportRow(row); return dtSorted; }=20
The template presentation consists of three slides containing data marke=
rs and formulas.
The second slide in our presentation contains the Continue modifier and RepeatSlide =
;marker. When used together on a slide, PowerPointWriter will import data o=
n to a slide until MaxRowsPerSlide is reached. Then, PowerPointWriter will =
copy the slide and continue adding data to the new slide. This will be repe=
ated until all the data in the data source has been imported. See Fitting Data on to =
Multiple Slides to learn more.
The third slide contains several f=
ormulas summarizing the information from the first two slides. Formulas sho=
uld follow the syntax %%=3DFORMULA_NAME(DataSource.DataCol). See Adding=
Formulas to a Presentation for more information and a list of supporte=
d formulas.
Our finished template will look like the following:=
public void Formulas() { using (PowerPointTemplate pptt =3D new PowerPointTemplate()) { pptt.Open("template.pptx"); //Get a Data Table of scores using the helper method DataTable ScoreData =3D GetScores(); //Create DataBindingProperties DataBindingProperties dataBindProps =3D pptt.CreateDataBindingProperties(); //Only import 10 rows on a slide dataBindProps.MaxRowsPerSlide =3D 10; //Bind the data pptt.BindData(ScoreData, "Scores", dataBindProps); pptt.Process(); pptt.Save(Page.Response, "ScoreReport.pptx", false); } } private DataTable GetScores() { DataTable dt =3D new DataTable(); dt.Columns.Add("StudentID", typeof(string)); dt.Columns.Add("Reading", typeof(int)); dt.Columns.Add("Writing", typeof(int)); dt.Columns.Add("Math", typeof(int)); dt.Columns.Add("Total", typeof(int)); Random rand =3D new Random(); int rScore, wScore, mScore; for (int i =3D 0; i < 30; ++i) { rScore =3D rand.Next(400, 800); wScore =3D rand.Next(400, 800); mScore =3D rand.Next(400, 800); dt.Rows.Add( string.Format("S{0:000000}", rand.NextDouble() * 1000000), rScore, wScore, mScore, rScore + wScore + mScore ); } DataTable dtSorted =3D dt.Clone(); foreach (DataRow row in dt.Select("", "StudentID asc")) dtSorted.ImportRow(row); return dtSorted; }=20
The resulting formula slide is below:
* Template:template.pptx<= br />* Sample output: output.= pptx