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

download the records into excel using Internet Explorer
Hey guys,
I am trying to download the records that I have in Visualforce page to excel. I am able to download the file in all other browsers except IE8. I do not want to download the whole VF page. I want to download the records that are in the VF page. Basically, the VF page has excel icon, which when clicked should download the records in excel format. I have tried using cache="true" and contenttype="application/vnd.ms-excel#filename.xls" but this downloads the whole VF page at the time of loading. I want to be able to download the records at the click of the icon instead. Any kind of help is appreciated.
Thanks!
hello.
first develope new page with pageblock table in this table data insert data that you want to download as excel and than add Apex:page tag Like this
and than on Download icon button you have a action method right ?
in this action method just redirect page to this page.
And be carefull both page(Download button containing page & this page block table containing page) should contain SAME controller.
hope this will help you.
if isnt than plz post situation at you stucked..
Thanks.
HI Hemant037,
Thanks a lot, I really appreciate your help.
renderRecords() is being called in actionFunction tag, with action="{!renderRecords}". So, I redirected from this page to the new VF page I created. But what this does is downloads the Visualforce page into excel. It does not download all the records, is there any other alternative
ok..
i am doing this same its working for me i am adding code here.
this is Page code for download page in which we will make a table of our data which we want to download as Excel.
now this is code for controller "DemoExcel" in which we will add code for get data into above table...
public with sharing class DemoExcel
{
public List<user> GetUser()
{
List<User> u=[select Id,Name,Email from User];
return u;
}
}
-- Now main page from which we will click button for download.
<apex:page controller="CsvExample" tabStyle="Wrapper__tab" >
<apex:form >
<apex:pageBlock >
<apex:pageBlockButtons >
<apex:commandButton value="Download as .Xls" action="{!DownloadXls}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
-----------------------------------------
Now we will add code for DownloadXls action in our controller
public with sharing class DemoExcel
{
public List<user> GetUser()
{
List<User> u=[select Id,Name,Email from User];
return u;
}
public PageReference DownloadXls()
{
return new PageReference('/apex/NAMEOFYOURFIRSTDOWNLOAD_PAGE');
}
}
now i think this will be helpful to you.
if it is than please mark it as solved.
Thanks.
Hi Hemant037,
I finally got it solved. In order to open it in internet explorer, I had to add the line cache="true" in the 2nd visualforce page. Thank you very much for all the help you have guided me through. I have one more issue on this topic if you have any idea about it. The excel download works completely fine in any browser.
After the file is downloaded, when I open it in Windows, all the records are fine, but when I download the file in mac and open it it add some html code in the first column of the excel. below is the code it shows:
if(!window.sfdcPage){window.sfdcPage = new ApexPage();} UserContext.initialize({"networkId":"","locale":"en_US","labelLastModified":"1356556072000","isDefaultNetwork":true,"today":"1/4/2013 2:24 PM","timeFormat":"h:mm a","userPreferences":[{"index":112,"name":"HideInlineEditSplash","value":false},{"index":114,"name":"OverrideTaskSendNotification","value":false},{"index":115,"name":"DefaultTaskSendNotification","value":false},{"index":119,"name":"HideUserLayoutStdFieldInfo","value":false},{"index":116,"name":"HideRPPWarning","value":false},{"index":87,"name":"HideInlineSchedulingSplash","value":false},{"index":88,"name":"HideCRUCNotification","value":false},{"index":89,"name":"HideNewPLESplash","value":false},{"index":90,"name":"HideNewPLEWarnIE6","value":false},{"index":122,"name":"HideOverrideSharingMessage","value":false},{"index":91,"name":"HideProfileILEWarn","value":false},{"index":93,"name":"HideProfileElvVideo","value":false},{"index":97,"name":"ShowPicklistEditSplash","value":false},{"index":92,"name":"HideDataCategorySplash","value":false},{"index":128,"name":"ShowDealView","value":false},{"index":129,"name". and more
This problem is only in mac. I tried creating a new vf page with some data, and did the excel download for it and still shows that code.
Please let me know if you have any idea about it and if it is something that can be solved.
Thanks!