Sample Code:
Visualforce page:
<apex:page controller="Sample" sidebar="false" action="{!fetch}" contentType="text/plain/#emp.txt" cache="false">
Employee Number : {!emp.Name}
Employee Name : {!emp.Employee_Name__c}
City : {!emp.City__c}
Email : {!emp.Email__c}
Description : {!emp.Description__c}
</apex:page>
Apex Controller:
public class Sample
{
public String empId;
public Employee__c emp {get;set;}
public Sample()
{
}
public void fetch()
{
empId = Apexpages.currentpage().getparameters().get('eid');
emp = [SELECT Name, Employee_Name__c, City__c, State__c, Email__c, Description__c FROM Employee__c WHERE ID =: empId];
}
}
Output: