CF7 – Creare un file excel



Posto questa interessante pagina di macromedia che spiega come generare un file excel partendo da una visualizzazione html di una query.

CFM 2 EXCEL

Per completezza riporto anche il codice:


<cfsetting enablecfoutputonly="Yes">
<!— Get employee info. —>
<cfquery name="GetEmps" datasource="cfdocexamples">
SELECT * FROM Employee
</cfquery>
<!— Set content type. —>
<cfcontent type="application/msexcel">
<!— Suggest default name for XLS file. —>
<!— "Content-Disposition" in cfheader also ensures
relatively correct Internet Explorer behavior. —>
<cfheader name="Content-Disposition" value="filename=Employees.xls">
<!— Format data using cfoutput and a table.
Excel converts the table to a spreadsheet.
The cfoutput tags around the table tags force output of the HTML when
using cfsetting enablecfoutputonly="Yes" —>
<cfoutput>
<table cols="4">
<cfloop query="GetEmps">
<tr>
<td>#Emp_ID#</td>
<td>#FirstName#</td>
<td>#LastName#</td>
</tr>
</cfloop>
</table>
</cfoutput>
 

Se trovi questo articolo su un blog diverso da “blog.merlinox.com” si tratta probabilmente di una copia non autorizzata. L’indirizzo originale di questo articolo è: CF7 – Creare un file excel scritto da .

2 Responses to CF7 – Creare un file excel

  1. Pingback: Incongruenza dati in Excel prodotti da Coldfusion | MrX

  2. Pingback: Coldfusion e Blob database object | MrX

Lascia un Commento

L'indirizzo email non verrà pubblicato. I campi obbligatori sono contrassegnati *

*

È possibile utilizzare questi tag ed attributi XHTML: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>