How to: schedule or batch-invoke SharePoint CSV exports
Every once in a while, a user of ExportZen, the SharePoint feature to export List data to CSV, enquires about scheduling.
One user wrote:
I have a sharepoint list whose data I want to use in peoplesoft. I need to export this list data as CSV everyday (need to schedule it).
Another user asked:
Is there any way to schedule ExportZen to export a Document List to CSV at specified intervals (i.e. 1 hr)? We need to get our document list into a reporting system using CSV (and stay current) and are looking for an automated way to do this.
In a perfect world, we would already offer you a "proper" to do this for you. Don't worry, this is on the medium-term product roadmap. Until we get there, there is another way which I want to show you today. So good news: you can start scheduling with this Right Now. This involves only a few setup steps that a later, integrated SharePoint Timer Job would be able to take care of fully. Overall, no rocket science is to be expected, though.
It just takes an executable...
As it turns out, starting with ExportZen build 1.2.0.5 (the newest at the time of writing this), when you deploy ExportZen to your SharePoint environment, an executable file ExportZen also gets deployed to the file system of your farm server. The setup wizard (actually, the WSP solution package) will place this executable in your (or your on 2010), ie. the full executable path is most likely C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\12\TEMPLATE\LAYOUTS\roxority_ExportZen\ExportZen (or a localized equivalent path).
Once you have defined a CSV export action, this can also be invoked by the above command-line program. It takes three arguments:
- The first argument needs to be "quoted" and specifies the full URL of the List or Document Library to be exported: for example "http://our-sharepoint/projects/Lists/Tasks".
- The second argument needs to be "quoted" and specifies both the URL of your export actions List and the numeric ID of your export action, separated by a slash, for example "http://our-sharepoint/ExportZenRules/1".
(How to find the ID? Simply "edit" your export rule and you'll find your browser URL contains something like EditForm.aspx?ID=x&... the 'x' will be a number and that's the ID you'll need instead of the '1' given in the above example URL.) - The third argument is also specified in quotation marks and specifies the full path of the exported .CSV file, to be stored directly in the SharePoint web front-end server file system.
Of course, you'll need to run ExportZen at all times:
- with no more and no less than those three arguments, and
- under a user account with read access to both Lists and write access to the specified file system location.
However, other than that you may invoke the tool in any way you wish, and do with its output file as you please.
Scheduling: not such a tough "job".
Once you have experimentally and interactively tested that your export also works with the ExportZen command-line utility too, you can schedule your exports using just the Task Scheduler that's part of Windows Server. (Naturally, the Task Scheduler service needs to auto-run for this.) Apart from setting the path and arguments to ExportZen as described in the previous paragraph, you should make sure the task
- will run under the appropriate user account,
- is set to run regardless of whether that user is logged on interactively or not, and
- of course, has your desired schedule applied.
As always, we're happy to help if you run into any obstacles: just drop us a line in the ExportZen Feedback Forum!
Reader Comments