• Perdedork
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 0
    Replies

Hi,

Is it possible to export to Excel with the filtering option turned on?  (Under Excel's 'Data' tab)

Presently, I have taken over manually exporting, leaving only the page intact (SF exports a page as HTML markup, and the data is exported as a table)

Here's an example of the Apex code:

public String exportGrid {
        get{
            String result = '<table><tr>'
                +'<td><b>Name</b></td><td><b>City</b></td><td><b>State</b></td>'
                +'<td><b>Zip</b></td><td><h>Country</h></td><td><b>E-Mail</b></td>'
                +'<td><b>Mobile</b></td><td><b>Home</b></td><td><b>Work</b></td>'
                +'</tr>';
            if( contactsExport == null )
                return '';
            for( Integer i = 0; i < contactsExport.size(); i++ )
            {
                result +='<tr>';
                
                if( contactsExport[i].name != null )    
                result +='<td><span>'+contactsExport[i].name+'</span></td>';
                else
                    result +='<td><span>&nbsp;</span></td>';
                ...
             }
       return result + '</table>';
        }
    }

 


Here's what the VF page look like:

<apex:page controller="ContactSearchController" apiVersion="26.0" contenttype="application/vnd.ms-excel#Search.xls" showChat="false" showHeader="false" standardStylesheets="false" sidebar="false" cache="true">
  <apex:pageBlock title="Contacts">
      <apex:outputText rendered="{!resultsAreLimited}"><b>These Results Were Limited to 4,000 Records</b></apex:outputText>
    <apex:outputText escape="false">{!exportGrid}</apex:outputText>
  </apex:pageBlock>
</apex:page>

 



Any help is appreciated.

Thanks,
Michael