In case you have no access to the workbench, can we download the query result from the Developer Console?
Build a Query in Developer Console
Open Developer Console, File > Open > Objects > select an object > click Open (or double click the object name).
Select the fields by hold the Ctrl key (and Shift key) for Windows users, then hit the
Query button, Id field will be auto-added.
Click the Execute button, developer console will open a tab with the query result.
Export query result to Excel file
This is tested in Chrome and chromium-based web engines (such as Edge and Opera), so not sure for Firefox and Safari.
Right-click on the query result and select Inspect.
Look for the table tag, then do "Copy element".
Open Excel and Paste to get the result.
Thank you but the "Copy element" doesn't work because when I tried to Paste it into Excel, it includes the HTML tags. None of the other Copy/Paste options worked. Could you please clarify the Excel version and the exact Paste option you're choosing. I ended up doing the query in the Workbench and exporting as CSV but I may not always have access to the workbench, so this could be very helpful to someone. I hope Salesforce will add this functionality out of the box someday.
ReplyDeleteI just try and it works, it is simply a copy and paste.
DeleteI am using Microsoft Excel version 2102 (Build 13801)
It took me a good 15 tries (and because I am stubborn, I kept doing it over and over and over again). I honestly don't know what I did differently the last time because, come on, this is copy and paste. But it didn't work the first bunch of times.
ReplyDeleteassume you manage to get it works!
DeleteI did. Thank you for this information. Very helpful.
Deleteawesome, glad to hear it 😊
DeleteJohan, this article was very helpful for me and your outlined solution worked for me.
ReplyDeleteThank You!
awesome, glad to hear!
DeleteIs it just me or does it only grab the first 2,000 records?
ReplyDeleteI am not sure how to get more 2K in Developer Console query editor, but you can use workbench to get all records https://workbench.developerforce.com/login.php
DeleteUse workbench application and download it as excel.
ReplyDeleteThank you for posting this. Works perfectly.
ReplyDeleteAwesome hack
ReplyDeleteNOTE: when pasting into Excel, use Paste Special > Unicode Text. This handles the xml and provides the desired result.
ReplyDeleteThis is a great hack, but I recommend you edit/caution users at the start of the article that this method only works for SOQL queries that are less than 2,000 rows.
ReplyDeleteThe query will display the correct count of returned rows (at the top of the selection results), but it will only display the first 2000 rows. This is similar to standard salesforce reports: they warn you that they can only display 2,000 records to the browser, but the report itself will export all the rows when the export option is selected.
Great hack, but use it carefully, and only for small data sets (under 2000 rows).