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

DataSet to Excel in Two steps – with Different Styles

Rate me:
Please Sign up or sign in to vote.
3.46/5 (34 votes)
30 Jul 2005 249.1K   11.3K   72   32
Cool Component exports DataSet(s) to Excel as Row-wise,Column-wise or Sheet-wise.

Sample Image - datasettoexcel.jpg

Introduction

This component exports a DataSet to Microsoft Excel. You can also export more than one multiple DataSets at a time. This component handles disposing of Excel objects and cleaning up of memory automatically. So there is no worry of memory leakage!! Just two lines of code to export your DataSet to Excel. This is a free component.

Note: You need Excel to be installed in your system.

Different Styles

Different styles that are available are:

  • Row Wise: Exports each DataTable in the DataSet in row-wise in Excel.
  • Column Wise: Exports each DataTable in the DataSet in column-wise in Excel.
  • Sheet Wise: Exports each DataTable in the DataSet in one worksheet.

Other features and formatting styles

You can set the following:

  • HeaderForeColor
  • HeaderBackColor
  • ItemForeColor
  • ItemBackColor
  • ItemAlternateBackColor
  • FontStyle
  • RowsSpace
  • ColumnSpace
  • TableSpace

Sample Code

C#
Utilities.ExcelExport.Export excel = 
                    new Utilities.ExcelExport.Export();
//Pass your Dataset and Specify the style.
excel.ExportDataToExcel(yourDataSet, 
            Utilities.ExcelExport.ExportStyle.RowWise);

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
United Arab Emirates United Arab Emirates
Software Engineer from India,Working in .NET for 2 years.

Comments and Discussions

 
QuestionApplication will not open but process does open Pin
Mariaelisau6-Jul-06 9:50
Mariaelisau6-Jul-06 9:50 
GeneralSpecifing Excel File Name Pin
Ali Hussian Al-Faraj6-Jun-06 21:20
Ali Hussian Al-Faraj6-Jun-06 21:20 
GeneralAssemblies missing Pin
lbispo4-May-06 5:30
professionallbispo4-May-06 5:30 
GeneralAccess Denied error Pin
srichikka2-May-06 23:01
srichikka2-May-06 23:01 
GeneralRe: Access Denied error Pin
Mukesh_B27-Aug-06 22:36
Mukesh_B27-Aug-06 22:36 
GeneralAccess is denied. Pin
oneforall201228-Apr-06 8:53
oneforall201228-Apr-06 8:53 
QuestionWhere's the article? Pin
exhaulted21-Feb-06 23:03
exhaulted21-Feb-06 23:03 
GeneralAccess is denied Pin
L. Des Lierres21-Feb-06 8:01
L. Des Lierres21-Feb-06 8:01 
Receive "Access is denied." on the following line.
excel = new Excel.ApplicationClass();

any tips to resolve this problem?

Thanks, H12

H12
GeneralRe: Access is denied Pin
L. Des Lierres28-Feb-06 14:08
L. Des Lierres28-Feb-06 14:08 
GeneralRe: Access is denied Pin
L. Des Lierres29-Jun-06 8:28
L. Des Lierres29-Jun-06 8:28 
GeneralRe: Access is denied Pin
L. Des Lierres29-Jun-06 8:29
L. Des Lierres29-Jun-06 8:29 
GeneralThis article is excellent Pin
Tigger997-Feb-06 16:39
Tigger997-Feb-06 16:39 
GeneralExporting Russian Characters to a CSV File Pin
MSJ_PK2-Aug-05 19:27
MSJ_PK2-Aug-05 19:27 

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.