Disclaimer: Sono nuovo in coldfusion. Sto cercando di creare un documento Excel 2010 con immagini e schede multiple. Sono stato in grado di ottenere questo output in XLS, ma non riesco a ottenere l'immagine nel file.come creare file xlsx usando coldfusion
Non sono stato in grado di trovare un esempio completo di come creare correttamente un file XLSx. Preferirei imparare la strada giusta e sviluppare le mie cattive abitudini in seguito, piuttosto che avere solo cattive abitudini.
Ecco un esempio:
<!--- Make CF export to Excel --->
<!--- This will create a XLS file --->
<!--- <cfheader name="Content-Disposition" value="attachment; filename=#URL.TRNo#_image.xls">
<cfcontent type="application/vnd.msexcel"> --->
<!--- This does not work to create an XLSX file --->
<cfheader name="Content-Disposition" value="inline; filename=#URL.TRNo#_image.xlsx">
<cfcontent type="application/vnd.openxmlformats-officedocument.spreadsheetml.sheet">
<cfparam name="URL.TRNo" default="AD0310">
<cfoutput>
<?xml version="1.0"?>
<Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet">
<ss:Styles>
<ss:Style ss:ID="Default" ss:Name="Normal">
<ss:Font ss:Size="11" ss:FontName="Calibri"/>
</ss:Style>
<ss:Style ss:ID="Left">
<ss:Alignment ss:Horizontal="Left"/>
</ss:Style>
<ss:Style ss:ID="Center">
<ss:Alignment ss:Horizontal="Center"/>
</ss:Style>
<ss:Style ss:ID="Right">
<ss:Alignment ss:Horizontal="Right"/>
</ss:Style>
</ss:Styles>
<Worksheet ss:Name="#URL.TRNo# page 1">
<ss:Table ss:DefaultColumnWidth="15" ss:DefaultRowHeight="15">
<Row ss:Height="51"><!--- Start Row 1 --->
<Cell ss:Index="1" ss:MergeAcross="9">
<Data ss:Type="String">Final Test Report</Data>
</Cell>
<Cell ss:Index="11" ss:MergeAcross="10" ss:StyleID="Center">
<Data ss:Type="String"><!--- <img src="http://wwwdev.elmsweb.ford.com/elmsGEN3/SafetyLab/FMVSS/ReportWriter/img/fordLogo_transparent_small.png" height="68" width="181" alt="13"> ---></Data>
</Cell>
<Cell ss:Index="22" ss:MergeAcross="9" ss:StyleID="Right">
<Data ss:Type="String">Confidential</Data>
</Cell>
</Row><!--- End Row 1 --->
<Row/><!--- Row 2 Blank --->
<Row><!--- Start Row 3 --->
<Cell ss:Index="1" ss:MergeAcross="1" ss:StyleID="Right">
<Data ss:Type="String">To:</Data>
</Cell>
<Cell ss:Index="3" ss:MergeAcross="12">
<Data ss:Type="String"></Data>
</Cell>
<Cell ss:Index="16" ss:MergeAcross="10" ss:StyleID="Right">
<Data ss:Type="String">Test Order:</Data>
</Cell>
<Cell ss:Index="27" ss:MergeAcross="4">
<Data ss:Type="String">#URL.TRNo#</Data>
</Cell>
</Row><!--- End Row 3 --->
</ss:Table>
</Worksheet>
</Workbook>
</cfoutput>
Hai provato a usare di ColdFusion funzioni built-in fogli di calcolo? [Documentazione per la funzione SpreadsheetNew] (http://help.adobe.com/en_US/ColdFusion/9.0/CFMLRef/WSc3ff6d0ea77859461172e0811cbec22c24-747b.html). Se si imposta il parametro 'xmlformat' su 'true' verrà creato un file .xlsx. _Hai bisogno almeno di ColdFusion 9 per queste funzioni_ –
Nessuno di questi renderà tecnicamente un file XLS o XLSX, realizzeranno un file XML servito in Excel. Puoi facilmente usare 'cfheader/content' dalla prima riga e cambiare l'estensione per farla apparire come un file XLSX, ma non sarà nel formato XLS/XLSX. – Busches
@ Miguel-F Grazie, penso che sia un passo nella giusta direzione. ma come può l'utente ottenere il file, non voglio memorizzarlo sul server? – BTThomas