Tuesday, September 9, 2008

Sample: Supply Initial Data in XAF from an Excel Sheet (without Excel)

As described here I usually like to supply some initial data to my XAF applications. However instead of manually I prefer to do it from data stored in Excel sheets because it allows me to load different sets of data for each development phase and even to migrate data from legacy applications.

Looking for a way to import data from an excel file without having Excel or the Office PIA installed on the computer, I found a very nice piece of code that loads a sheet's data into a datatable using only OLEDB.  Once the data is in a Datatable, load it into a XAF application is a piece of cake.

I prepared a basic sample, that can download here, which loads Customers (and their addresses) from a Excel File into XPO objects.

Tip: To avoid file path nightmares I normally place the excel file in at the root level of the "Module" project and configure it to be deployed to the output directory.  See the picture below.



Which technique do you use to load data into your XAF applications? Any feedback will be appreciated.

2 comments:

Anonymous said...

Many thanks
I am a novice in AFX
This example solves one of the N problems I'm having
Muchas gracias

alfonso.teodori@tin.it

Dani Mora said...

il tuo benvenuto alfonso,

let me know if you think I can help with any of your other N-1 XAF problems :-)