function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Atlas Can 23Atlas Can 23 

Visualforce Excel Export Issue

I'm trying to export a Visualforce page as an Excel document.

I've looked at similar questions and the exported file is saved as a webpage embedded in excel which is prompted as unsupported/corrupt in mobile devices.

It was suggested to use html tags instead of visualforce ones to enforce proper format but this also didn't work. Below is the sample table code in the VF page.

Any thoughts? Thanks.
 
<apex:page id="Stock_Flexible2"
       standardController="Account"
       extensions="StockPDFController"
       sidebar="false"
       showHeader="false"
       contentType="application/application/vnd.ms-excel#Flexlist.xls"
       applyBodyTag="false"
       applyHtmlTag="false"
       cache="true"
       standardStylesheets="false"    
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<div>
            <table style="width:100%">

            <h1> Sample Table </h1>

            <tr>
                <td>a</td>
                <td>b No</td>
                <td>c</td>
            </tr>

                <apex:repeat value="{!flexibleStocks}" var="flex">

                    <tr>
                        <td width="%10"> {!flex.Order_Serial__c}  </td>
                    </tr>

                    <tr>
                        <td width="10%">  {!flex.Order_No__c} </td>
                    </tr>

                    <tr>
                        <td width="10%"> {!flex.Queue__c} </td>
                    </tr>
                </apex:repeat>
            </table>
</div>

 
Gulafsha MohammedGulafsha Mohammed
Hello,
Just keep one application in contentType for example:
<apex:page controller="URR" contentType="application/vnd.ms-excel#abc.xls">

Please mark this as best answer if it has solved your issue.
Thanks 
Gulafsha
Raj VakatiRaj Vakati
Try this code
 
<apex:page id="Stock_Flexible2"
       standardController="Account"
       extensions="StockPDFController"
       sidebar="false"
       showHeader="false"
       contentType="application/vnd.ms-excel#Flexlist.xls"
       applyBodyTag="false"
       applyHtmlTag="false"
       cache="true"
       standardStylesheets="false"    
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8"/>
</head>
<div>
            <table style="width:100%">

            <h1> Sample Table </h1>

            <tr>
                <td>a</td>
                <td>b No</td>
                <td>c</td>
            </tr>

                <apex:repeat value="{!flexibleStocks}" var="flex">

                    <tr>
                        <td width="%10"> {!flex.Order_Serial__c}  </td>
                    </tr>

                    <tr>
                        <td width="10%">  {!flex.Order_No__c} </td>
                    </tr>

                    <tr>
                        <td width="10%"> {!flex.Queue__c} </td>
                    </tr>
                </apex:repeat>
            </table>
</div>