You need to sign in to do that
Don't have an account?

Visualforce to Mac
Hi,
Have two problems.
1. When the visualforce page below runs it saves in downloads with no association to excel. I am guessing the content type is wrong but I have not found the right one.
2. When I manually add the .xls extension and open in excel the name field (code highlighted in red) has some strange data.
Thanks
Ross
<apex:page standardController="Trip__c" cache="true" contenttype="application/vnd.ms-excel" showHeader="false"> <h1>TRIP DETAILS</h1> <p></p> <br></br> <apex:dataTable value="{!Trip__c}" var="T" id="TripTable" headerClass="tablehead" columnClasses="tabledata"> <apex:column value="{!T.Name}" headerValue="Trip Code"/> <apex:column value="{!T.Trip_Title__c}" headerValue="Trip Title" /> <apex:column value="{!T.Start_Date__c}" headerValue="Start Date"/> <apex:column value="{!T.End_Date__c}" headerValue="End Date"/> </apex:dataTable> <p></p> <br></br> <H1>GUIDE</H1> <br></br> <p></p> <apex:dataTable value="{!Trip__c.Guides__r}" var="G" id="Guide" headerClass="tablehead" columnClasses="tabledata"> <apex:column value="{!G.Guide__r.Name}" headerValue="Guide Name"/> <apex:column value="{!G.Guide__r.MobilePhone}" headerValue="Mobile"/> <apex:column value="{!G.Guide__r.Dietary_Requirements__c}" headerValue="Diet"/> <apex:column value="{!G.Guide__r.Medical_Conditions__c}" headerValue="Medical"/> </apex:dataTable> <p></p> <br></br> <H1>VEHICLES</H1> <br></br> <p></p> <apex:dataTable value="{!Trip__c}" var="O" id="Vehicles" headerClass="tablehead" columnClasses="tabledata"> <apex:column value="{!O.Vehicles__c}" headerValue="Vechicles"/> </apex:dataTable> <p></p> <br></br> <H1>BOOKING DETAILS</H1> <br></br> <p></p> <apex:dataTable value="{!Trip__c.Travellers__r}" var="B" id="BookingTable" headerClass="tablehead" columnClasses="tabledata"> <apex:column value="{!B.Traveller__r.Name}" headerValue="Traveller"/> <apex:column value="{!B.Traveller__r.Birthdate}" headerValue="DOB"/> <apex:column value="{!B.Traveller__r.Total_Number_of_Trips__c}" headerValue="Number of Trips"/> <apex:column value="{!B.Traveller__r.Dietary_Requirements__c}" headerValue="Diet"/> <apex:column value="{!B.Traveller__r.Medical_Conditions__c}" headerValue="Medical"/> <apex:column value="{!B.Traveller__r.Chest_Size__c}" headerValue="Chest"/> <apex:column value="{!B.Traveller__r.Hand__c}" headerValue="Hand"/> <apex:column value="{!B.Traveller__r.Height__c}" headerValue="Height"/> <apex:column value="{!B.Traveller__r.MobilePhone}" headerValue="Mobile"/> <apex:column value="{!B.Traveller__r.Emergency_Contact__c}" headerValue="Emergency Contact"/> <apex:column value="{!B.Traveller__r.Emergency_Number__c}" headerValue="Emergency Number"/> <apex:column value="{!B.Cancelled_Formula__c}" headerValue="Cancelled"/> </apex:dataTable> <p></p> <br></br> <H1>TRAVELLER NOTES</H1> <br></br> <p></p> <apex:dataTable value="{!Trip__c.Travellers__r}" var="TN" id="TripNote" headerClass="tablehead" columnClasses="tabledata"> <apex:column value="{!TN.Traveller__r.Name}" headerValue="Traveller"/> <apex:column value="{!TN.Traveller__r.MailingCountry}" headerValue="Country of Residence"/> <apex:column value="{!TN.Equipment__c}" headerValue="Equipment"/> <apex:column value="{!TN.Traveller_Notes__c}" headerValue="Notes"/> </apex:dataTable> <p></p> <br></br> <H1>ACCOMMODATION DETAILS</H1> <br></br> <p></p> <apex:dataTable value="{!Trip__c.Rooms__r}" var="R" id="RoomTable" headerClass="tablehead" columnClasses="tabledata"> <apex:column value="{!R.Accommodation__r.Name}" headerValue="Accommodation Name"/> <apex:column value="{!R.Accommodation__r.Accommodation_Phone__c}" headerValue="Phone Number"/> <apex:column value="{!R.Accommodation__r.Start_Date__c}" headerValue="Start Date"/> <apex:column value="{!R.Accommodation__r.End_Date__c}" headerValue="End Date"/> <apex:column value="{!R.Accommodation__r.Nights__c}" headerValue="Nights"/> <apex:column value="{!R.Room_Type__c}" headerValue="Room Type"/> <apex:column value="{!R.Occupant_1__r.Name}" headerValue="Occupant 1"/> <apex:column value="{!R.Occupant_2__r.Name}" headerValue="Occupant 2"/> <apex:column value="{!R.Occupant_3__r.Name}" headerValue="Occupant 3"/> <apex:column value="{!R.Occupant_4__r.Name}" headerValue="Occupant 4"/> <apex:column value="{!R.Room_Note__c}" headerValue="Room Note"/> </apex:dataTable> <p></p> <br></br> <H1>TRIP NOTES</H1> <br></br> <apex:outputText value="{!Trip__c.Trip_Notes__c}"></apex:outputText> <p></p> <br></br> </apex:page>
The following works fine. FYI I noticed if you use apex tags like outputField you get a bunch of javascript in the first element of your excel page. Sticking to outputText is the way to go.
All Answers
Try "application/ms-excel" for starters, although your current contenttype should work.
I think your bigger issue is that you have html formatting within your Visualforce page which will likely monkey up the conversion.
Thanks I tried but it did not work, code below.
The following works fine. FYI I noticed if you use apex tags like outputField you get a bunch of javascript in the first element of your excel page. Sticking to outputText is the way to go.
Thanks for this I have replicated the code below and changed MyFile to Trip_Schedule.xls
The file is cleaner and the extension is added associating it to excel.
Seems to be working, I think on Windows there is no need to have the .xls extension it seems to be there automatically.
Thanks again
Ross