RavenDB 2.5 Features: Import Data to Excel
Join the DZone community and get the full member experience.Join For Free
i wonder what it says about ravendb that we spend time doing excel integration .
at any rate, we have the following documents inside ravendb:
and we want to get this data into excel. not only that, but we want this to be something more than just a flat file. we want something that will auto update itself.
we start by defining the shape of the output, using a transformer.
then we go an visit the following url:
- http://localhost:8080/databases/musicbox – the server & database that we are querying.
- streams/query/raven/documentsbyentityname?query=tag:albums – stream the results of querying the index raven/documentsbyentityname for all tag:albums (effectively, give me all the albums).
- resultstransformer=albums/shapedforexcel – transform the results using the specified transformer.
- format=excel – output this in a format that excel will find easy to understand
the output looks like this:
now, let us take this baby and push this to excel. we create a new document, and then go to the data tab, and then to from text:
we have a file open dialog, and we paste the previous url as the source, then hit enter.
we have to deal with the import wizard, just hit next on the first page.
we mark the input as comma delimited, and then hit finish.
we now need to select where it would go on the document:
and now we have the data inside excel:
we aren’t done yet, we have the data in, now we need to tell excel to refresh it:
click on the connections button, where you’ll see something like this:
go to properties:
- uncheck prompt for file name on refresh
- check refresh data when opening the file
close the file, go to your database and change something. open the file again, and you can see the new values in there.
you have now create an excel file that can automatically pull data from ravendb and give your users immediate access to the data in a format that they are very comfortable with.
Published at DZone with permission of Oren Eini, DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.