• Mohan t 7
  • NEWBIE
  • 0 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies
I am facing an issue when exporting visual force page data as excel. As it exporting whole page ......The problem was like i have vf page with title and button...so when i click the button the data in pageblock table should download. but it download  including button as well . how to avoid button on page or how to download only pageblock table data.

VF code --


<apex:page Standardcontroller="Account" extensions="accNotes" standardStylesheets="false" contentType="{!IF(isExport = true, 'application/vnd.ms-excel#contacts.xls', '')}" cache="true">
<apex:form >
 <apex:pageBlock id="pgb">
 <apex:pageBlockSection columns="8" >
 <apex:outputPanel layout="block">
 <b><apex:outputLabel style="margin" value="Notes & Attachments"></apex:outputLabel></b>

 <apex:commandButton id="button" style="margin-left:80px;" value="Export as Excel" action="{!exportToExcel}" reRender="">     /////**** This is also printing on excel page when downloaded******************///  
 </apex:commandButton>

 </apex:outputPanel>
 </apex:pageBlockSection>
 
 <apex:pageBlockSection >
 <apex:pageBlockTable value="{!Recordsall}"  var="n"> 
 <apex:column style="overflow:hidden;white-space:nowrap" value="{!acc.AccountNumber}">
 <apex:facet name="header">Account Number</apex:facet>
 </apex:column>
 <apex:column style="overflow:hidden;white-space:nowrap" value="{!acc.name}">
 <apex:facet name="header">Account Name</apex:facet>
 </apex:pageBlockSection>
 </apex:pageBlock>
 </apex:form>
 </apex:page>