Message-ID: <1376409386.7645.1711616687190.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_7644_677790782.1711616687190" ------=_Part_7644_677790782.1711616687190 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html
The PowerPointTemplate object supports some basic formulas. Each= of the formulas will perform a specific operation on the values referenced= . Formulas are evaluated for all values of the column in the data source, r= egardless of how many of the values are actually displayed in the document.=
=20The formula must follow the syntax %%=3DFORMULA_NAME(DataSource.Co=
lumnName)
where:
PowerPointTemplate.BindData
method is called.=
There must be a call to PowerPointTemplate.BindData
to bind=
a data source to the template, however, you do not need to include a full =
data marker (%%=3DDataSource.ColumnName) in the template to use the formula=
.
PowerPointWriter supports the following data marker formulas:
=20AVERAGE | =20
Calculates the average of the column values = | =20
---|---|
COUNT | =20
Returns the number of values (that is, the n= umber of rows in the data source) of the column | =20
COUNTA | =20
Returns the number of non-null values of the= column | =20
MAX | =20
Returns the maximum value from the column = p> | =20
MIN | =20
Returns the minimum value from the column = p> | =20
PRODUCT | =20
Calculates the product of the column values = | =20
STDEV | =20
Returns the standard deviation of the column= values, treating the values as a sample | =20
STDEVP | =20
Returns the standard deviation of the column= values, treating the values as a population | =20
SUM | =20
Calculates the sum of the column values = | =20
VAR | =20
Returns the variance of the column values, t= reating the values as a sample | =20
VARP | =20
Returns the variance of the column values, t= reating the values as a population | =20
The example below uses formulas to display the average, standard deviati= on, maximum, and minimum college entrance exam scores of a group of fiction= al students as part of a table including their individual scores.
=20 =20The following code opens the template and binds data to it using the Set= DataSource and SetRepeatBlock methods, then streams the resulting document = to the user:
=20protected void AddFormulas(object sender, EventArgs e) { PowerPointTemplate pptt =3D new PowerPointTemplate(); pptt.Open("FormulaTemplate.pptx"); =20 //Get a Data Table of scores using the helper method DataTable ScoreData =3D GetScores(); //Create DataBindingProperties DataBindingProperties dataBindProps =3D pptt.CreateDataBindingProperti= es(); //Bind the data pptt.BindData(ScoreData, "Data", dataBindProps); =20 pptt.Process(); pptt.Save(Response, "ScoreReport.docx", false); } private DataTable GetScores() { DataTable dt =3D new DataTable(); dt.Columns.Add("StudentID", typeof(string)); dt.Columns.Add("ReadingScore", typeof(int)); dt.Columns.Add("WritingScore", typeof(int)); dt.Columns.Add("MathScore", typeof(int)); dt.Columns.Add("Score", 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() * 1= 000000), rScore, wScore, mScore, rScore + wScore + mScore ); } DataTable dtSorted =3D dt.Clone(); foreach (DataRow row in dt.Select("", "StudentID asc&qu= ot;)) dtSorted.ImportRow(row); return dtSorted; }=20
The formulas are evaluated by PowerPointTemplate, as you can see in the = sample output slide:
=20 =20