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
Rakshith RamachandraRakshith Ramachandra 

Generating real-time automated excel reports using Salesforce?

I'm new to Salesforce and I'm trying to automate report generation. Basically every time I want that specific report, I want it to be directly generated in Excel Realtime. What is the best way of doing this?

Is it by using Apex classes to run the SOQL query and VisualForce page to create an Excel report?

Are there other ways of doing it?

Thanks in advance.
Best Answer chosen by Rakshith Ramachandra
Swayam@SalesforceGuySwayam@SalesforceGuy
Hi,

if you can render a VF page the way you want it to look (grid-style), you can change the content type in the apex:page tab to be contenttype="application/vnd.ms-excel" to get it into Excel format.

 

Once you do that - you can wrap it up in an Http object method in an APEX class.  Call the VF page within APEX, parse the response into a blob variable, then you can slide that blob right into an Attachment record.  I just did this for a customer of mine who wanted to take a VF page rendering as PDF with a single button press generate and attach it to the parent record.  Works slick...the user just clicks the button and is immediately returned back to the originating page with the attachment created.

If you're looking to systematize it more - you can replace "button click" with "another APEX method" to do the same thing.

If that's the approach you want to take, let me know and I can pass along some code structure to get you started.  =)

--
Thanks,
Swayam

 

All Answers

Swayam@SalesforceGuySwayam@SalesforceGuy
Hi,

if you can render a VF page the way you want it to look (grid-style), you can change the content type in the apex:page tab to be contenttype="application/vnd.ms-excel" to get it into Excel format.

 

Once you do that - you can wrap it up in an Http object method in an APEX class.  Call the VF page within APEX, parse the response into a blob variable, then you can slide that blob right into an Attachment record.  I just did this for a customer of mine who wanted to take a VF page rendering as PDF with a single button press generate and attach it to the parent record.  Works slick...the user just clicks the button and is immediately returned back to the originating page with the attachment created.

If you're looking to systematize it more - you can replace "button click" with "another APEX method" to do the same thing.

If that's the approach you want to take, let me know and I can pass along some code structure to get you started.  =)

--
Thanks,
Swayam

 
This was selected as the best answer
Rakshith RamachandraRakshith Ramachandra
Excellent. This is exactly what I want. You're a life saver. 

If you can send me any details or code snippets. That would be wonderful. You can email me at 31rakshith@gmail.com

Rakshith
Rakshith RamachandraRakshith Ramachandra
Hi Swayam,

Just wanted to confirm if you had sent me any material to guide me on the above problem. Please point me in the right direction.

Rakshith