So I'm trying to build a Visualforce page that takes some data from an individual record, displays it in a table and populates the appropriate fields, as well as leaving some fields empty, and exports it to an excel file. Every time I have tried this however, excel tells me that the file format and extension don't match, and that the file could be corrupted or unsafe. I can still open it in Excel, but all formatting is gone. Does anyone here know what I can do?

The idea is to have all formatting done in Visualforce so once it's converted to excel, all the user has to do is fill in the necessary information and not have to worry about formatting.

My VF page is as follows:

<apex:page standardController="Inquiry__c" showHeader="false" standardStylesheets="false" 
contenttype="application/vnd.ms-excel#Inquiry Sheet.xls" > 

        padding: 5px;
    .mainHeader {
        background: #ff5050;
        font-weight: bold;

    .gridHeader {
        background: #cecece;
        font-weight: bold;

    <apex:form id="changeStatusForm">

        <apex:panelGrid columns="1" width="1200" cellpadding="0" cellspacing="0" rules="all" frame="box">
            <apex:panelGrid columns="1" width="100%" cellpadding="0" cellspacing="0" rules="all" > 

                <apex:outputPanel style="padding:5px;" layout="block" styleClass="mainHeader">    

                    <apex:outputText value="INQUIRY SHEET"/> 


            <apex:panelGrid columns="4" width="100%" cellpadding="0" cellspacing="0" rules="all" id="theGrid">

                    <apex:outputText value="Product Name:"/>
                     <apex:outputText value="{!Inquiry__c.Product_Description__c}"/>
                    <apex:outputText value="Item No. of the supplier:"/>
                    <apex:outputText value="{!Inquiry__c.Inquiry_ID__c}"/> 
                    <apex:outputText value="Offer Deadline:"/>
                    <apex:outputText value="{!Inquiry__c.End_Date__c}"/>
                    <apex:outputText value="Offer Dated"/>
                    <apex:outputText value=" "/> <!-- Empty fields to be filled out in excel -->
                    <apex:outputText value="Offer valid until:"/>
                    <apex:outputText value="{!Inquiry__c.Product_Delivery_Date__c}"/>
                    <apex:outputText value="Offer Dated"/>
                    <apex:outputText value=" "/> 
                    <apex:outputText value="Customer:"/>
                    <apex:outputText value=" "/>
                    <apex:outputText value="Offer Valid Until:"/>
                    <apex:outputText value=" "/> 





You must log in to answer this question.

Browse other questions tagged .