+ Start a Discussion

Reports from Apex Class/Visualforce page

Please let me know if anyone knows how to handle reports from apex class/pages.


Here is the query; generating standard reports are very limited conditions (no matter what kind of report it is). I would like to generate my report with three level conditions (column level) from Visualforce page or apex class, could you please tell me whether it is that possible or not? If positive, please guide me the way of doing that.


Thank you


Are you looking to create custom reports in visualforce?  You can certainly do that, but you'll have to create your SOQL query dynamically based on the user inputs.  Its really no different to any other VF page - capture some inputs, retrieve matching data and output it.  Bear in mind that you have to do everything from scratch though.


Hey Bob,


Thank you so much for your responce.

Let me explain the scenario that I’m facing, I have to send a mail with every day calling data to my client.


For that I’m haging with two issues;

1.) I have created a report with two level row and column conditioning, but not able to attach that report in a mail.

2.) Client suggested adding one more level column grouping condition is make more sense and I guess that is not possible with standard reports so I presumed we need to develop a custom report using visual force/Apex class, Can I achieve that? Again how to attach/call that VF/report in a mail?


Thank you in advance.


You can set up scheduled reports that send an email with the report, but these only go to users.


Creating a report equivalent in apex/vf requires you to execute the SOQL and then render the results on the page.  If you want to email it, I think you'll need to get the content of the page as PDF and programattically create the email.  The downside to this is I don't think its possible to get content as PDF from a scheduled apex class, so you might end up with a text or html based compromise.


Thank you Bob,


Once again Salesforce proved it has limited functions/features, not sure what is the purpose of sending mails to Users onlyL. Ugh!!!!

Yeah I made a VF page with Excel content type and required SOQLs in controller class, while I’m executing it gives me an Excel sheet, which what I want..but the question is how to send a mail with attachment!!! …can I achieve that in Salesforce?

Also I have created a webservice which sending mails periodically but not sure how to import Salesforce generated XL files.


Thank you I advance