views:

175

answers:

2

is there a workaround to use the cfdocument tag to save a page/file as an excel sheet instead of a PDF file?

I already have a process set up to make pdf files and email them out and would like to give my customers the option of getting an excel file instead. It would be nice if I could reuse the code I already have instead of having to rewrite it in POI or something like that.

+4  A: 

The type of data witihn a PDF is not usually the same type of data that makes sense for Excel. That being said, there are multiple other ways to create Excel spreadhseets.

In ColdFusion 9, it's native. Just use the cfspreadsheet. In CF8... well, it looks like you have POI. So use that. ;) Ben Nadel also has a nice wrapper for POI so you can consider that too.

The thing is - you will not be able to go from CFDOCUMENT to a spreadsheet since it is really a different type of data.

CF Jedi Master
+1  A: 

In ColdFusion 9 use the cfspreadsheet tag and/or spreadsheet functions. That creates a real Excel file.

In ColdFusion 8 and below the easiest way is to use the html table > Excel hack/trick. Put your data in a standard html table, save them in a file with a .xls extension and email them to your users. When the user opens the file Excel will convert the html table to an Excel spreadsheet. You could also send the content to the browser by adding at the top of the page. With this method make sure that you are only sending an html table for best results.

Sam Farmer