G'day Scott

We are looking to use XML to generate Excel and Word files using CF.  Your 
example is great - thanks!  Do you know of any other resources that would 
assist us with doing this sort of thing?  Have you run into any limitations or 
problems?

We have an app that uses COM generate Excel and Word files using CF.  As you 
probably know, it's not particularly stable!  So we're looking at alternatives.

Cheers

Nathan

> I would advise don't use com method if you can, com means that
> you always have to use windows for your server. Also The process that
> runs coldfusion on your server needs access to the registery to view
> the com object, so potentially opens up more paths for hacking.
> 
> If you use have office xp , then you can read/write excel xml 
> spreadsheets. So you can use the xmlparse command to pickup an
> existing excel spreadsheet and update it with your report data.
> 
> Heres an example of creating an excel dynamically, that does not use 
> com.
> 
> 
> <!---1- open file--->
> <cffile action="read" file="#vpath#\templates\master\SpreadSheet.xml" 
> variable="xml_summdet">
> 
> <!---2- turn text data into xml--->
> 
> <CFSET myxmldoc = XmlParse(xml_summdet,"no")>
> 
> <!---3- find a worksheet--->
> 
> <cfset mywb = xmlsearch(myxmldoc,
> "/ss:Workbook/ss:[EMAIL PROTECTED]:Name='Sheet1']/ss:Table/")>
> 
> <!---4- it is a lot easier to copy an existing rather than create one 
> from scratch--->
> 
> <cfset temprow = myxmldoc.xmlroot.worksheet[2].table[1].row[1]>
> <cfset  clone = Duplicate(temprow)>
> 
> <!---5- now amend clone--->
> 
> <cfset clone.cell[3].data.xmltext = "#dbrowvalue#";>
> <cfset clone.cell[3].xmlattributes.type = "String">
> 
> <!---6-append clone onto worksheet and update rowcount (or else excel 
> wil fail--->
> 
> 
> <cfscript>
> ArrayAppend(myxmldoc.Workbook.WorkSheet[1].table[1].xmlchildren, 
> clone);
> 
> myxmldoc.Workbook.WorkSheet[1].table[1].xmlattributes.expandedrowcount 
> = val(myxmldoc.Workbook.WorkSheet[1].table[1].xmlattributes.
> expandedrowcount)+1;
> </cfscript>
> 
> 
> <!---7- write file--->
> 
> <cfset myoutput=tostring(myxmldoc)>
> <cffile action="write" file="Listing.xml" OUTPUT="#myoutput#" 
> nameconflict="overwrite">
> 
> 
> 
> I would accept that is slightly trickier than com, but once you do do 
> it once, they'll be no holding you back.
> 
> Cheers 
Scott

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking 
application. Start tracking and documenting hours spent on a project or with a 
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67

Message: http://www.houseoffusion.com/lists.cfm/link=i:4:201464
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

Reply via email to