Coldfusion with Keith Diehl
-
Upload
refresh-annapolis-valley -
Category
Technology
-
view
438 -
download
1
description
Transcript of Coldfusion with Keith Diehl
How ColdFusion saved me from a week of grunt work
Using SQL Server and Coldfusion to generate 600 Word Documents.
Buy One Class – Get One Class 50% offuntil December 15
Why ColdFusion?
• Quick learning curve• Similar style to HTML with opening and closing tags• Supported by Adobe and frequently updated with new features
• ColdFusion isn’t free but also not that expensive• Hosted ColdFusion accounts are about $30 a month• Free Developer Edition
Can you guess what this does?
<cfloop index="i" from="1" to="10">
<cfoutput> <p> #i# </p> </cfoutput>
</cfloop>
Can I get this outline as a Word Doc?
Ummm… No.
<cfoutput>
<h1>#database.h1#</h1><h2>#database.h2#</h2>
#database.classOutline#
</cfoutput>
I need all of our outlines in Word
… super.
Can ColdFusion come to my rescue?
Yup!
Step 1: Get the info from the database
<cfquery name="allOutlines" datasource="datasource" username="username" password="password">
SELECT ID, Name,
Days, H1, ClassOutline,FileName
FROM classroomTable
ORDER BY Name
</cfquery>
Step 2: Output class info into a variable
<cfoutput query="allOutlines">
<cfsavecontent variable="myDocument">
<html xmlns:w="urn:schemas-microsoft-com:office:word"> <!--- Head tag instructs Word to start up a certain way, specifically in print view. ---> <head> <xml> <w:WordDocument> <w:View>Print</w:View> <w:SpellingState>Clean</w:SpellingState> <w:GrammarState>Clean</w:GrammarState> <w:Compatibility> <w:BreakWrappedTables/> <w:SnapToGridInCell/> <w:WrapTextWithPunct/> <w:UseAsianBreakRules/> </w:Compatibility> <w:DoNotOptimizeForBrowser/> </w:WordDocument> </xml> </head>
<body>
<cfoutput>
<h1>#allOutlines.Name#</h1><p>#allOutlines.Days# <cfif allOutlines.Days GT "1">days<cfelse>day</cfif></p>
#allOutlines.classOutline#
</cfoutput> </body></html></cfsavecontent>
<cfscript>
FileWrite("Server:\word-outlines\#allOutlines.ID#-#allOutlines.FileName#.doc", "#myDocument#");
</cfscript>
</cfoutput>
Step 3: Write variable into Word Doc
This is my lonely directory
my directory with lots of friends…
SUPER CODER!