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

Export to Excel using Visualforce



I have issue with exporting to excel using Visualforce:


I am having around 30 columns and around 1000 records....


When I click on export to excel button then it shows error - "unable to read file". Then when we open that file then data is present but it shows that error of unable to read file.


Also if I reduce the records by limiting the query to 500 then I don't get the error. If I keep all records and reduce the columns to 4 or 5 then also error does not come but if I keep all columns and all records then error is coming...


VF page line:

<apex:page controller="CONTROLLER" contentType="application/" cache="true">


Has anyone faced anything like this?? I came across few blogs and few communities but found no alternative that solves my problem.




What happens if you try to render this as a regular VF page - do you see any errors or exceptions?


Nope. When used as normal VF page then it comes nicely. No errors or exception come.


Could it be that there is data in one or more of the last 500 records that blows the formatting for excel in some way?  Have you tried changing it so that you drop the first 500 records to see if it still works correctly when using the last 500?  That would indicate it isn't a problem with the data itself.


Nope. Data does not seem to be an issue. I tried using different set of records. Moreover there are no text area or other big fields.

There are date fields and I removed them and tried but still same issue so i believe data is not an issue.

This seem to be like excel issue only but I need strong statement which says what is the exact issue and whether it is possible to solve it or no.

P.S. - I am using excel 2003. I tried in office 2010. It shows some warning and once we click yes then it opens the file nicely but in 2003 it shows "Unable to read file"


Just because you have tried a different set of records doesn't mean that it isn't a data issue.  It may be that there is a particular field value causing a problem and that appears in several records.

Hi Bob,

Even I face the same problem while exporting to excel. Either it shows " web page not available" or "unable to read file". It would be of great help if you give some inputs here.
I have also 1700+ records to be exported to excel