Click here to Skip to main content
15,889,651 members
Articles / Programming Languages / C#
Article

Export excel data to a Dataset

Rate me:
Please Sign up or sign in to vote.
4.48/5 (24 votes)
27 Nov 20031 min read 250K   9.6K   67   37
A usercontrol that exports from excel to a dataset without needing MS office to be installed.

Image 1

Introduction

If you ever need to add functionality to your application to enable you to export an excel file as a Dataset, instead of coding it by yourself, use this control. Using this you can let the user select the column names of the datatable in the exported Dataset. You can also restrict the user to select column names from a list of specified column names.

Background

This control uses System.Data.OleDbClient namespace to connect to the excel file as a data store. It doesn't need MS Excel to be installed on the computer.

Using the code

  1. Copy Gopal.Data.Transform.dll to your application folder. Right click on the toolbox and select 'Add/Remove components' as shown below.

    Image 2

  2. Now select 'ExcelExportControl' from 'Gopal.Data.Transform' assembly and press 'OK' as shown below.

    Image 3

  3. The 'ExcelExportControl' has now been added to the toolbox and can be used.

    Image 4

  4. This control will now allow you to load an excel file. You can select the first row as the column names by checking the checkbox which says so.
  5. The first tabpage lets you preview all the sheets in the excel file.

    Image 5

  6. The second tabpage lets you select an output dataset name, datatable name and column names too.

    Image 6

The download package has the source code, assembly and a demo form using the assembly.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions

 
AnswerRe: numeric field values are not retrieved Pin
DaberElay23-Aug-06 12:35
DaberElay23-Aug-06 12:35 
GeneralRe: numeric field values are not retrieved Pin
ugurcan7724-Aug-06 7:09
ugurcan7724-Aug-06 7:09 
QuestionWhat about protected excel documents? Pin
binolino6-Apr-04 12:36
binolino6-Apr-04 12:36 
AnswerRe: What about protected excel documents? Pin
pirklk9-Feb-05 11:16
pirklk9-Feb-05 11:16 
QuestionHow do I enable the control? Pin
jo278223-Feb-04 4:56
jo278223-Feb-04 4:56 
AnswerRe: How do I enable the control? Pin
ksgopal23-Feb-04 5:11
ksgopal23-Feb-04 5:11 
GeneralRe: How do I enable the control? Pin
jo278223-Feb-04 5:37
jo278223-Feb-04 5:37 
QuestionWhat are the techniques Pin
Jörgen Sigvardsson30-Nov-03 2:14
Jörgen Sigvardsson30-Nov-03 2:14 
AnswerRe: What are the techniques Pin
ksgopal30-Nov-03 9:24
ksgopal30-Nov-03 9:24 
GeneralRe: What are the techniques Pin
Jörgen Sigvardsson30-Nov-03 9:54
Jörgen Sigvardsson30-Nov-03 9:54 
GeneralRe: What are the techniques Pin
cn_wpf7-Dec-03 14:12
cn_wpf7-Dec-03 14:12 
GeneralRe: What are the techniques Pin
ksgopal7-Dec-03 23:28
ksgopal7-Dec-03 23:28 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.