Coldfusion with Keith Diehl

17
How ColdFusion saved me from a week of grunt work Using SQL Server and Coldfusion to generate 600 Word Documents.

description

 

Transcript of Coldfusion with Keith Diehl

Page 1: Coldfusion with Keith Diehl

How ColdFusion saved me from a week of grunt work

Using SQL Server and Coldfusion to generate 600 Word Documents.

Page 2: Coldfusion with Keith Diehl
Page 3: Coldfusion with Keith Diehl

Buy One Class – Get One Class 50% offuntil December 15

Page 4: Coldfusion with Keith Diehl

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

Page 5: Coldfusion with Keith Diehl

Can you guess what this does?

<cfloop index="i" from="1" to="10">

<cfoutput> <p> #i# </p> </cfoutput>

</cfloop>

Page 6: Coldfusion with Keith Diehl
Page 7: Coldfusion with Keith Diehl

Can I get this outline as a Word Doc?

Ummm… No.

Page 8: Coldfusion with Keith Diehl
Page 9: Coldfusion with Keith Diehl

<cfoutput>

<h1>#database.h1#</h1><h2>#database.h2#</h2>

#database.classOutline#

</cfoutput>

Page 10: Coldfusion with Keith Diehl

I need all of our outlines in Word

… super.

Page 11: Coldfusion with Keith Diehl

Can ColdFusion come to my rescue?

Yup!

Page 12: Coldfusion with Keith Diehl

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>

Page 13: Coldfusion with Keith Diehl

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>

Page 14: Coldfusion with Keith Diehl

<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

Page 15: Coldfusion with Keith Diehl

This is my lonely directory

Page 16: Coldfusion with Keith Diehl

my directory with lots of friends…

Page 17: Coldfusion with Keith Diehl

SUPER CODER!