+ Start a Discussion
yudyud 

Export a pageBlockTable to Excel

Hi

 

How do I export a pageBlockTable to Excel.

The page does not uses a standart controller but a custom and the pageBlockTable is not the only item on the page.

 

Thanks

Yitzchak

Best Answer chosen by Admin (Salesforce Developers) 
yudyud

Hi

 

I found the problem - My page was contained a <apex:form> element.

When I remove it everything becomes ok

 

Thanks anyway.

 

Yitzchak 

All Answers

JimRaeJimRae

create a duplicate version of your page with the contenttype set to excel.

 

Check out an article on it here:

 

http://blog.sforce.com/sforce/2008/12/visualforce-to-excel.html

yudyud

Thanks.

I already did it but then the generated file can be opened only on excel 2007 (with a warning message) but not in excel 2003.

Should I need to add something else, except adding the "contenttype" attribute?

 

Yitzchak 

JimRaeJimRae

Did you try it with an explicit file name?

 

Something like this:

 

 

<apex:page standardController="Account" contenttype="application/vnd.ms-excel#myacct.xls">

 

 

yudyud

Yes I do.

My page code is:

 

<apex:page controller="IncomeRecognitionController" contenttype="application/vnd.ms-excel#test1.xls" cache="true">

 But the file could not opened on excel 2003.

 

Yitzchak 

 

yudyud

Hi

 

I found the problem - My page was contained a <apex:form> element.

When I remove it everything becomes ok

 

Thanks anyway.

 

Yitzchak 

This was selected as the best answer