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
sri14sri14 

fetched 'soql query' results can we put directly into .xls

Plz I need apex batch class for below requirement

'fetched query results can we put directly into .xls'

 

 

Thank you for your time!

 

Sincerely

sri

LegendLegend

Hi,

 

Below is the sample code for your requirement:

 

public class ExcelDownload{

	public List<Account> getExcelExport(){
	
		List<Account> acc = [SELECT Id, Name FROM Account Limit 10];
		return acc;
	}
}

 

<apex:page controller="ExcelDownload" contentType="application/vnd.ms-excel#TestExcel" id="pg">
	<apex:pageBlock id="pgBlock">
		<apex:pageBlockTable value="{!excelExport}" var="excel">
			<apex:column value="{!excel.Id}"/>
			<apex:column value="{!excel.Name}"/>
		</apex:pageBlock>	
	</apex:pageBlock>
</apex:page>

 

AmitSahuAmitSahu

Please go through this link :

 

http://blogs.developerforce.com/systems-integrator/2008/12/visualforce-to-excel.html

 

This is ONLY for reference..

 

Call the visuallforce page from the button... and in the controller manupulate the resord you want.

sri14sri14

I need apex batch class, for fetched query results put into .xls file to transfer via vf email templates.

sri14sri14

I need apex batch class, for fetched query results put into .xls file and to transfer via vf email templates.