Recently I came across with a requirement where I need to generate excel file from SFDC data of some objects. Traditionally we do this by making csv file. But here the challenge was that i need to fetch data from multiple objects and make single Excel File with different Sheet (tabs), each sheet belongs to single object and contains that object data. So here is code, how i achieve it.
Here is the link you can download the code from :SFMultiSheetExcelGenerator
http://www.aslambari.com/downloads/SFMultiSheetExcelGenerator.zip
The folder contains some VF pages and some classes. There is one demo VF page also which contains a button which generates the sample excel file with contacts and accounts data. You can see the working demo here:
https://labsprojects-developer-edition.ap1.force.com/MultiSheetExcelGenerateDemoThere is a component which is responsible to generate the excel data. You can see the sample code in "MultiSheetExcelGenerate.page" VF page. Here is the code , how you use this component:
<apex:page controller="MultiSheetExcelGenerate" sidebar="false" showHeader="false" contentType="application/vnd.ms-excel#myfile.xls">
<c:multisheetexcelcomponent datamodel="{!dm}" />
</apex:page>
Have a look and use the code as per your need and mail me with your valuable feed backs as always :)
Thanks
Aslam Bari
30 comments:
this is awesome! keep up the great work!
G. LO
Again useful stuff. :)
Aslam, this is very cool! If your requirement stems from a need to quickly make mass edits across multiple objects, you might be interested in AppBuddy. http://www.salesforceappbuddy.com
Thanks for sharing, this is useful staff.
Great job.Aslam, this is indeed useful
Thanks for the code...but it giving me an error when i try to download it.
Not Found
The requested URL /downloads/SFMultiSheetExcelGenerator.zip was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
This is good help me add the images and cell merge
Thanks for sharing this awesome stuff...
thanks so much for this feature It really help me with some requirements I had.
I only have one question, perhaps is something that only happens to me. But trying to open the generated xls file on Microsoft's excel 2007 the program prompts me a message about the file content format and it's extension. If I go ahead and open the file it's all correct but I couldn't understand why it is complaining. Something regarding the mime type perhaps.
Thanks Aslam for the this code. This is awesome.
Can you please let me know how to write test classes for these classes
I guess one is already there in package.... isn't it?
nope...
Can you please upload it, if you have any..
hi aslam,
i cant able to find the http://www.aslambari.com/downloads/SFMultiSheetExcelGenerator.zip
in this link. can u please send me the code to my mail id (l.venkat.ramanan@gmail.com.
i am in need of this code to finish my requirement, so please send me the code for this yaar
Dude,
If I am correct this code will fall into apex governor limits and will not extract more than 1000 rows ?
What is with data model is it a date type?
Hi Aslam,
I faced a problem while using it. The problem is-
I have created a generalized code which will work for all objects. I made it using SObject. When I print datamodel list using system.debug it gives me expected output.
The problem is when I download the excel file and open it, it gives me an error that "file is corrupted, could not open"
Hi
i think issue is that you are not using the excel version which is 2003 onwards?
Hi,
I am using excel 2010. And am also facing problem when am downloading larger data. It is giving me error as collection limit exceeding than 1000 for datamodel.
and Thanks, I have solved the earlier problem of file corruption.
Hi,
I am using excel 2010. And am also facing problem when am downloading larger data. It is giving me error as collection limit exceeding than 1000 for datamodel.
Hi
I have a list of records..but somehow I am unable to display each record of the list in the columns of an excel..can u plz help ???
Hi,
can you please help me to save this excel file in attachment. very urgent!!!
Hi Aslam,
Great stuff but I faces a problem. I gave a hyperlink to the 'generate' page in one of the pages. But if i click on the page, along wiht the excel sheet download pop-up, the 'generate' page opens up as well, which doesn't happen in the link you mentioned. Please suggest.
Best regards,
Hari
Hi Aslam,
its really wonderful code,i used this code to download the excel and i changed this code into generic code and its working fine but i am facing a strange problem when i am passing fields explicitly in headers list then its working fine but if i pass dynamic fields value then its not working and showing me error that key value is not found in map key but if i do checking by debug then all values are there i am unable to understand this problem please help me its very urgent
Hi i am not able to download the zip file and see any code ... pl help me ..
Hi i am not able to download the zip file...any help on this...
Hi, the download link is not available anymore. Kindly fix. Thank you.
This links is not working..
http://www.aslambari.com/downloads/SFMultiSheetExcelGenerator.zip
Hi there,
This link(http://www.aslambari.com/downloads/SFMultiSheetExcelGenerator.zip) is not working. Could you please update the URL.
Thanks
Post a Comment