Sunday, August 23, 2009

Dynamic Power Point presentation using ColdFusion

The below code snippets will show you how you can generate a dynamic power point using ColdFusion 9.
This is the start of the code:

<cfpresentation format="ppt" destination="f:\test\a.ppt" title="" overwrite="yes">
The code for the first slide:

<body background="file:///f:/temp/bg1.jpg">
<h1 style="color:YELLOW"> This is pure HTML page </h1>
<h2 style="color:RED"> Sub title </h2>
<li> test 1 </li>
<li> test 2 </li>
<li> test 3 </li>
The code for the second slide. This is a dynamic slide having a chart generated from a database:

<cfquery name="GetSalaries" datasource="cfdocexamples">
SELECT Departmt.Dept_Name,
FROM Departmt, Employee
WHERE Departmt.Dept_ID = Employee.Dept_ID

<cfquery dbtype = "query" name = "DataTable">
AVG(Salary) AS avgSal,
SUM(Salary) AS sumSal
FROM GetSalaries
GROUP BY Dept_Name

<!--- Reformat the generated numbers to show only thousands. --->
<cfloop index = "i" from = "1" to = "##DataTable.RecordCount##">
<cfset DataTable.sumSal[i] = Round(DataTable.sumSal[i]/1000)*1000>
<cfset DataTable.avgSal[i] = Round(DataTable.avgSal[i]/1000)*1000>

<!--- Bar graph, from Query of Queries --->
<cfchart format="jpg"
yaxistitle="Salary Average">

<cfchartseries type="bar"

<cfchartdata item="Facilities" value="35000">

The code for the third slide. This shows an example of text formatting using HTML:

<cfpresentationslide >
<body style="color:GREEN" >

<h4 style="color:BLUE"> Some examples of HTML text formatting</h4>
<p><b>This text is bold</b></p>
<p><strong>This text is strong</strong></p>
<p><big>This text is big</big></p>
<p><em>This text is emphasized</em></p>
<p><i>This text is italic</i></p>
<p><small>This text is small</small></p>
<p>This is<sub> subscript</sub> and <sup>superscript</sup></p>
Close the slides:

The generated first slide:
The generated second slide:

The generated third slide:

No comments:

Post a Comment