After Thought

Reading excel spread sheet as strongly typed objects

with one comment

Recently, I was working on a prototype application that required data to be read from many different Excel spreadsheets (both xls and xlsx versions) each containing a large number of worksheets.  I started with the usual way of creating one DTO (Data Transfer Object) for each worksheet and then pulling the data from Excel through OleDBReader. It became repetitive to do the same thing over and over for every single worksheet. After quick thought, I decided to write a simple tool that can solve this problem of data access (as I didn’t want to spend a lot of time just building the infrastructure) .

The end result is a tool that can generate an assembly containing Strongly Typed DTO’s by querying the excel (as I didn’t want to create them manually) that can then be included as a reference in our project and a library that provides methods to query the excel data through a single repository class. By abstracting out the DTO generation and accessing data from excel, I can now concentrate on building the prototype application that can deliver some business value.

Code for this is available on Git Hub: https://github.com/mvba/ExcelMapper

Download the BuildDTOsFromExcel.exe and ExcelMapper.dll with an example usage here.

You can read a brief description on how to use ExcelMapper here

We can definitely improve this tool further, but it works if you are looking for a quick solution to query the excel sheets. If you are interested in improving this tool, please feel free to comment.

About these ads

Written by shashankshetty

May 8, 2009 at 9:25 pm

One Response

Subscribe to comments with RSS.

  1. Reading excel spread sheet as strongly typed objects « Shashank’s Blog…

    Thank you for submitting this cool story – Trackback from DotNetShoutout…

    DotNetShoutout

    May 11, 2009 at 4:48 pm


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

%d bloggers like this: