You need to sign in to do that
Don't have an account?
Jarosław Kołodziejczyk
XLS file exported using Visualforce won't open in Excel
Hi,
I have a really urgent matter to solve.
The file i'm creating using visualforce will simply not open in excel (it opens in libreOffice), i got the error "The file format differs from the format that the file name extension specifies".
Here's my vfp code:
I have a really urgent matter to solve.
The file i'm creating using visualforce will simply not open in excel (it opens in libreOffice), i got the error "The file format differs from the format that the file name extension specifies".
Here's my vfp code:
<apex:page controller="createFlockCSVController" contentType="application/vnd.ms-excel#Wstawienie.xls" cache="true"> <apex:outputText value="{!xmlHeader}"/> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:html="http://www.w3.org/TR/REC-html40"> <Styles> <Style ss:ID="s1"> <Alignment/> <Borders/> <Font ss:Bold="1"/> <Interior ss:Pattern="Solid" ss:Color="#c8fcff"/> <NumberFormat/> <Protection/> </Style> </Styles> <Worksheet ss:Name="Flocks"> <Table x:FullColumns="1" x:FullRows="1"> <Column ss:Width="80"/> <Column ss:Width="70"/> <Column ss:Width="180"/> <Column ss:Width="180"/> <Column ss:Width="170"/> <Column ss:Width="180"/> <Column ss:Width="150"/> <Column ss:Width="150"/> <Column ss:Width="120"/> <Column ss:Width="160"/> <Column ss:Width="120"/> <Column ss:Width="100"/> <Row> <Cell ss:Width="100" ss:StyleID="s1"><Data ss:Type="String" >Ferma</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Kurnik</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Wstawienie</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Liczba ptaków</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Wylęgarnia</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Rasa</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Typ paszy</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Wszystkie upadki</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >FCR</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >EWW</Data></Cell> </Row> <apex:repeat value="{!flock}" var="flock"> <Row> <Cell><Data ss:Type="String">{!flock.House__r.Farm__r.Name}</Data></Cell> <Cell><Data ss:Type="String">{!flock.House__r.Name}</Data></Cell> <Cell><Data ss:Type="String">{!flock.Flock_number__c}</Data></Cell> <Cell><Data ss:Type="String">{!flock.Birds_at_arrival__c}</Data></Cell> <Cell><Data ss:Type="String">{!flock.Hatchery__c}</Data></Cell> <Cell><Data ss:Type="String">{!flock.Genetic_Line__c}</Data></Cell> <Cell><Data ss:Type="String">{!flock.Feed_Type__c}</Data></Cell> <Cell><Data ss:Type="String">{!flock.Total_dead__c}</Data></Cell> <Cell><Data ss:Type="String">{!flock.FCR__c}</Data></Cell> <Cell><Data ss:Type="String">{!flock.EWW__c}</Data></Cell> </Row> </apex:repeat> <Row> </Row> </Table> <Table x:FullColumns="1" x:FullRows="1"> <Column/> <Row> <Cell ss:StyleID="s1"><Data ss:Type="String" >Data</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Wiek(dni)</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Śr. waga[g]</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Upadki</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Selekcja</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Szacowana liczba ptaków</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Spożycie paszy [g/szt]</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Spożycie wody [ml/szt]</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Kod paszy skarmianej</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Kod paszy dostarczonej</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Leczenie</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Notatka</Data></Cell> </Row> <apex:repeat value="{!flock.Flock_stats__r}" var="flockStats"> <Row> <Cell><Data ss:Type="String">{!flockStats.DateHidden__c}</Data></Cell> <Cell><Data ss:Type="String">{!flockStats.Day__c}</Data></Cell> <Cell><Data ss:Type="String">{!flockStats.Avg_body_weight__c}</Data></Cell> <Cell><Data ss:Type="String">{!flockStats.Daily_dead__c}</Data></Cell> <Cell><Data ss:Type="String">{!flockStats.Daily_selection__c}</Data></Cell> <Cell><Data ss:Type="String">{!flockStats.Estimated_number_of_birds__c}</Data></Cell> <Cell><Data ss:Type="String">{!flockStats.Daily_feed_consumed__c}</Data></Cell> <Cell><Data ss:Type="String">{!flockStats.Daily_water_consumption__c}</Data></Cell> <Cell><Data ss:Type="String">{!flockStats.Feed_code__c}</Data></Cell> <Cell><Data ss:Type="String">{!flockStats.Feed_code_delivered__c}</Data></Cell> <Cell><Data ss:Type="String">{!flockStats.Treatment__c}</Data></Cell> <Cell><Data ss:Type="String">{!flockStats.Note__c}</Data></Cell> </Row> </apex:repeat> <Row></Row> </Table> <Table x:FullColumns="1" x:FullRows="1"> <Column/> <Row> <Cell ss:StyleID="s1"><Data ss:Type="String" >Data</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Dzień:</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Waga transportu netto u hodowcy [kg]</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Liczba ptaków u hodowcy [szt]</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Waga całkowita netto z ubojni [kg]</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Liczba ptaków z ubojni [szt]</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Średnia waga [kg]</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Waga konfiskaty [kg]</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Waga martwych kurczaków [kg]</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Odpad/Zwrot [kg]</Data></Cell> <Cell ss:StyleID="s1"><Data ss:Type="String" >Waga do rozliczenia [kg]</Data></Cell> </Row> <apex:repeat value="{!thinningList}" var="thinning"> <Row> <Cell><Data ss:Type="String">{!thinning.DateHidden__c}</Data></Cell> <Cell><Data ss:Type="String">{!thinning.Day__c}</Data></Cell> <Cell><Data ss:Type="String">{!thinning.Total_weight_at_farm__c}</Data></Cell> <Cell><Data ss:Type="String">{!thinning.Birds_thinned_at_farm__c}</Data></Cell> <Cell><Data ss:Type="String">{!thinning.Total_weight_at_Slaughterhouse__c}</Data></Cell> <Cell><Data ss:Type="String">{!thinning.Birds_at_slaughterhouse__c}</Data></Cell> <Cell><Data ss:Type="String">{!thinning.Avg_body_weight__c}</Data></Cell> <Cell><Data ss:Type="String">{!thinning.Weight_of_confiscation__c}</Data></Cell> <Cell><Data ss:Type="String">{!thinning.Waste_Return__c}</Data></Cell> <Cell><Data ss:Type="String">{!thinning.Weight_after_reductions__c}</Data></Cell> </Row> </apex:repeat> </Table> </Worksheet> </Workbook> </apex:page>
xmlheader ='<?xml version="1.0"?><?mso-application progid="Excel.Sheet"?>';Any idea why this happens?