Pageblock table export as .xls or excell

Visualforce Page :

<apex:page controller="exportExcel" action="{!exportToExcel}" readOnly="true" contentType="application/vnd.ms-excel#ConsignmentSearchData.xlsx">  
    <apex:pageBlock >
        <apex:pageBlockTable value="{!lstConsignmentSearchData}" var="x">
           <apex:column headerValue="First Name">
                {!x.First_Name__c}
            </apex:column>
            <apex:column headerValue="Last Name">
                {!x.Last_Name__c}
            </apex:column>
            <apex:column headerValue="Location">
                {!x.Location__c}
            </apex:column>
            <apex:column headerValue="Client">
                {!x.Client__c}
            </apex:column>
             <apex:column headerValue="Primary Skill">
                {!x.Primary_Skill__c}
            </apex:column>
             <apex:column headerValue="Primary Skill Proficiency">
                {!x.Primar_Skill_Proficiency__c}
            </apex:column>
             <apex:column headerValue="Exp In Primary Skill(Months)">
                {!x.Experience_in_Primary_Skill__c}
            </apex:column>
            <apex:column headerValue="Secondary Skill">
                {!x.Secondary_Skill__c}
            </apex:column>
            <apex:column headerValue="Secondary Skill Proficiency">
                {!x.Secondary_Skill_Proficiency__c}
            </apex:column>
            <apex:column headerValue="Exp In Secondary Skill(Months)">
                {!x.Experience_in_Secondary_Skill__c}
            </apex:column>
        </apex:pageBlockTable>
    </apex:pageBlock>  

</apex:page>

Controller :

public class exportExcel {
    public string  skillEvent{get;set;}
    public string  clientEvent{get;set;}
    public string  locationEvent{get;set;}
    public string  proficiencyEvent{get;set;}
    public string LoginPageId {get;set;}
    public exportExcel(){
        LoginPageId = ApexPages.CurrentPage().getParameters().get('LoginPageId');
        skillEvent       = apexpages.currentpage().getparameters().get('skillEvent');
        clientEvent      = apexpages.currentpage().getparameters().get('clientEvent');
        locationEvent    = apexpages.currentpage().getparameters().get('locationEvent');
        proficiencyEvent = apexpages.currentpage().getparameters().get('proficiencyEvent');
    }  
    public List<Base_Data__c> lstConsignmentSearchData {get;set;}
    public void exportToExcel(){
          lstConsignmentSearchData =[Select Client__c,
                                Contact__c,
                                Email_Address__c,
                                Experience_in_Primary_Skill__c,
                                Experience_in_Secondary_Skill__c,
                                First_Name__c,
                                Last_Name__c,
                                Location__c,
                                Primary_Skill__c,
                                Secondary_Skill__c,
                                Primar_Skill_Proficiency__c,
                                Secondary_Skill_Proficiency__c from Base_Data__c where
                                ((Primary_Skill__c= :skillEvent or Client__c= :clientEvent or Location__c=: locationEvent) or
                                (primar_Skill_Proficiency__c=: proficiencyEvent)) order by Primar_Skill_Proficiency__c desc,First_Name__c asc];
    //pagereference pref = new pagereference('/apex/EmployeeRegistrationPagesfdc1');
    //pref.getParameters().put('LoginPageId',LoginPageId);
    //return pref;
    }
 }

No comments:

Featured

What is Cryptography in salesforce and what are all the algorithms provided by them ?

A). It is a security protocal between two systems. Lets say we are integration two systems without any encrytion mechanism then hackers wil...

Popular