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
Manoj Kumar 468Manoj Kumar 468 

I have create a VFpage with PageblockTable which has header and footer and using contentType to export it in excel format, but in export file the header and footer are coming together at the top of the column.I need to use pageBlockTable only.

Manoj Kumar 468Manoj Kumar 468
Can anyone please tell the solution for it?
 
Avishek Nanda 14Avishek Nanda 14
Hi Manoj,

You can put the data table inside a div and use Jquery or Java Scrip onClick function which would download the table.
$("#btnExport").click(function(e) {
2
    window.open('data:application/vnd.ms-excel,' + $('#dvData').html());
3
    e.preventDefault();
4
});​
Regards,
Avishek 
Manoj Kumar 468Manoj Kumar 468
Restriction ,that  I have to use pageblock table only to show data .But while exporting the data the Header and footer is comming together and below that column data is show.
 
Manoj Kumar 468Manoj Kumar 468
<apex:page standardController="Account" recordSetVar="accounts"  contentType="text/csv#contentfile.xls">
  <apex:pageBlock >
    <apex:pageBlockSection >
    <apex:pageBlockSectionItem >
       
    </apex:pageBlockSectionItem>
    <apex:pageBlockSectionItem >
        
    </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
    <apex:pageBlockSection >
    <apex:pageBlockTable value="{!accounts}" var="a">
   <apex:column headerValue="TEST" footerValue="FooterTEST" value="{!a.name}"/>
     </apex:pageBlockTable>
      </apex:pageBlockSection>
  </apex:pageBlock>
</apex:page>

User-added imageOutput In excel