+ Start a Discussion
AravindBabu512AravindBabu512 

Export Datatable from VF to excel

Hi,

 

It seems pretty odd, but I am not able to export the data from my VF to an excel. The content-type argument of apex:page tag works fine with other browsers and not IE. But my business team uses only IE. Is this is a problem with Salesforce IE functionality. Or am I missing something.

 

<apex:page Controller="LSR" contentType="application/vnd.ms-excel">
  <apex:pageBlock >
    <apex:pageBlockTable value="{!lsrList}" var="l">
      <apex:column headerValue="Agency Name"> {!l.loc_name} </apex:column>
      <apex:column headerValue="Location Code"> {!l.loc_code} </apex:column>
      <apex:column headerValue="Status"> {!l.loc_status} </apex:column>         
      <apex:column headerValue="Evaluated Status"> {!l.ob_status} </apex:column>      
    </apex:pageBlockTable>    
  </apex:pageBlock>

</apex:page>

 This is my code, this works fine with other browsers but not in IE. Any workaround to get this done.

 

Thanks.

 

Best Answer chosen by Admin (Salesforce Developers) 
AravindBabu512AravindBabu512

I dont have any great logic, its just a SOQL on all accounts. And by the way I tried it in IE9 and it works. This is strange. Quite not able to understand why the same code works for other browsers, IE9.

 

But got a catch now, when i add the cache parameter it worked in IE8 too. Guess cache parameter has some connection to this. 

 

 

Thanks,

Aravind

All Answers

Naidu PothiniNaidu Pothini
contentType="application/vnd.ms-excel.xls"

Did you try adding it an extension. i am not sure but its working fine in IE for me.

 

Gud luck

AravindBabu512AravindBabu512

No, it does not work still. I am getting an error 'Unable to Open this internet site, The requested site is unavailable or cannot be found'

 

I am working in my sandbox, does this got to do something in sandbox and prod environments, I guess not.

 

Thanks,

Aravind

Prafull G.Prafull G.
What version of IE you are using?

Its working on IE9.

Cheers!
AravindBabu512AravindBabu512

I am using IE8. Is this a known issue..?

 

Thanks,

Aravind

Prafull G.Prafull G.

No. There is no issue with IE actually.

 

I tried the same in IE8 as well. I am using very basic example 

 

<apex:page StandardController="Account" contentType="application/vnd.ms-excel">
<apex:pageBlock >
<apex:pageBlockTable value="{!account.Contacts}" var="con">
<apex:column headerValue="Contact Name"> {!con.Name} </apex:column>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:page>

 

and its working with all browsers.

 

Can you check the content you are getting from LSR controller?

 

AravindBabu512AravindBabu512

I dont have any great logic, its just a SOQL on all accounts. And by the way I tried it in IE9 and it works. This is strange. Quite not able to understand why the same code works for other browsers, IE9.

 

But got a catch now, when i add the cache parameter it worked in IE8 too. Guess cache parameter has some connection to this. 

 

 

Thanks,

Aravind

This was selected as the best answer